This commit is contained in:
Zelong Kuang
2025-11-16 22:05:10 +11:00
parent 8a7a911295
commit 506025930b
7 changed files with 151 additions and 119 deletions

View File

@@ -1,67 +1,70 @@
(setq-default tab-width 4)
(setq doom-font (font-spec :family "Maple Mono" :size 20)) (setq doom-font (font-spec :family "Maple Mono" :size 20))
(add-to-list 'default-frame-alist '(height . 53)) (add-to-list 'default-frame-alist '(height . 53))
(add-to-list 'default-frame-alist '(width . 120)) (add-to-list 'default-frame-alist '(width . 120))
(setq catppuccin-flavor 'mocha)
(setq doom-theme 'catppuccin) (setq doom-theme 'catppuccin)
(setq display-line-numbers-type 'relative) (setq display-line-numbers-type 'relative)
(setq org-directory "~/org/") (setq org-directory "~/org/")
(setq catppuccin-flavor 'mocha) (use-package! yasnippet
(catppuccin-reload) :config
(defun my-yas-try-expanding-auto-snippets ()
(after! yasnippet (when yas-minor-mode
(defun my-yas-try-expanding-auto-snippets () (let ((yas-buffer-local-condition ''(require-snippet-condition . auto)))
(when yas-minor-mode (yas-expand))))
(let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets)
(yas-expand)))) )
(add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets))
;; accept completion from copilot and fallback to company ;; accept completion from copilot and fallback to company
(use-package! copilot (use-package! copilot
:hook (prog-mode . copilot-mode) :hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map :bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion) ("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion) ("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word) ("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word) ("C-<tab>" . 'copilot-accept-completion-by-word)
("C-n" . 'copilot-next-completion) ("C-n" . 'copilot-next-completion)
("C-p" . 'copilot-previous-completion)) ("C-p" . 'copilot-previous-completion))
:config :config
(add-to-list 'copilot-indentation-alist '(prog-mode 2)) (add-to-list 'copilot-indentation-alist '(prog-mode 2))
(add-to-list 'copilot-indentation-alist '(org-mode 2)) (add-to-list 'copilot-indentation-alist '(org-mode 2))
(add-to-list 'copilot-indentation-alist '(text-mode 2)) (add-to-list 'copilot-indentation-alist '(text-mode 2))
(add-to-list 'copilot-indentation-alist '(clojure-mode 2)) (add-to-list 'copilot-indentation-alist '(clojure-mode 2))
(add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2)))
(use-package! typst-ts-mode (use-package! typst-ts-mode
:custom :init
;; (typst-ts-watch-options "--open") (add-hook 'typst-ts-mode-hook #'eglot-ensure)
(typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) :custom
(typst-ts-mode-enable-raw-blocks-highlight t) ;; (typst-ts-watch-options "--open")
:config (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory))
(keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu)) (typst-ts-mode-enable-raw-blocks-highlight t)
:config
(keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu))
(with-eval-after-load 'eglot (with-eval-after-load 'eglot
(with-eval-after-load 'typst-ts-mode (with-eval-after-load 'typst-ts-mode
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
`((typst-ts-mode) . `((typst-ts-mode) .
,(eglot-alternatives `(,typst-ts-lsp-download-path ,(eglot-alternatives `(,"tinymist"
"tinymist" "typst-lsp"))))))
"typst-lsp"))))))
(use-package! websocket) (use-package! websocket)
(use-package! typst-preview (use-package! typst-preview
;; :load-path "path/to/typst-preview.el" ;; if installed manually ;; :load-path "path/to/typst-preview.el" ;; if installed manually
:init :init
(setq typst-preview-autostart t) ; start preview automatically when typst-preview-mode is activated (setq typst-preview-autostart t) ; start preview automatically when typst-preview-mode is activated
;; (setq typst-preview-open-browser-automatically t) ; open browser automatically when typst-preview-start is run ;; (setq typst-preview-open-browser-automatically t) ; open browser automatically when typst-preview-start is run
:custom :custom
(typst-preview-browser "default") ; this is the default option; other options are `eaf-browser' or `xwidget'. (typst-preview-browser "default") ; this is the default option; other options are `eaf-browser' or `xwidget'.
(typst-preview-invert-colors "auto") ; invert colors depending on system theme (typst-preview-invert-colors "auto") ; invert colors depending on system theme
(typst-preview-executable "tinymist") ; path to tinymist binary (relative or absolute) (typst-preview-executable "tinymist") ; path to tinymist binary (relative or absolute)
(typst-preview-partial-rendering t) ; enable partial rendering (typst-preview-partial-rendering t) ; enable partial rendering
:config :config
(define-key typst-preview-mode-map (kbd "C-c C-j") 'typst-preview-send-position) (define-key typst-preview-mode-map (kbd "C-c C-j") 'typst-preview-send-position)
(define-key typst-ts-mode-map (kbd "C-c C-l") #'typst-preview-mode)) (define-key typst-ts-mode-map (kbd "C-c C-l") #'typst-preview-mode))

View File

@@ -1,83 +1,85 @@
* My doom config * My doom config
** Some tweak
*** change indent size
#+begin_src emacs-lisp
(setq-default tab-width 4)
#+end_src
** Appearance settings ** Appearance settings
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq doom-font (font-spec :family "Maple Mono" :size 20)) (setq doom-font (font-spec :family "Maple Mono" :size 20))
(add-to-list 'default-frame-alist '(height . 53)) (add-to-list 'default-frame-alist '(height . 53))
(add-to-list 'default-frame-alist '(width . 120)) (add-to-list 'default-frame-alist '(width . 120))
(setq catppuccin-flavor 'mocha)
(setq doom-theme 'catppuccin) (setq doom-theme 'catppuccin)
(setq display-line-numbers-type 'relative) (setq display-line-numbers-type 'relative)
(setq org-directory "~/org/") (setq org-directory "~/org/")
#+end_src #+end_src
*** Themes *** Themes
Catppuccin **** Catppuccin
#+begin_src emacs-lisp :tangle packages.el #+begin_src emacs-lisp :tangle packages.el
(package! catppuccin-theme) (package! catppuccin-theme)
#+end_src #+end_src
#+begin_src emacs-lisp
(setq catppuccin-flavor 'mocha)
(catppuccin-reload)
#+end_src
** Plugins ** Plugins
*** Yasnippet *** Yasnippet
This enables the feature of auto-expanding snippets when matching the pattern This enables the feature of auto-expanding snippets when matching the pattern
#+begin_src emacs-lisp #+begin_src emacs-lisp
(after! yasnippet (use-package! yasnippet
(defun my-yas-try-expanding-auto-snippets () :config
(when yas-minor-mode (defun my-yas-try-expanding-auto-snippets ()
(let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) (when yas-minor-mode
(yas-expand)))) (let ((yas-buffer-local-condition ''(require-snippet-condition . auto)))
(add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets)) (yas-expand))))
(add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets)
)
#+end_src #+end_src
*** Eat (deprecated) *** Eat (deprecated)
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(package! eat (package! eat
:recipe (:type git :recipe (:type git
:host codeberg :host codeberg
:repo "akib/emacs-eat" :repo "akib/emacs-eat"
:files ("*.el" ("term" "term/*.el") "*.texi" :files ("*.el" ("term" "term/*.el") "*.texi"
"*.ti" ("terminfo/e" "terminfo/e/*") "*.ti" ("terminfo/e" "terminfo/e/*")
("terminfo/65" "terminfo/65/*") ("terminfo/65" "terminfo/65/*")
("integration" "integration/*") ("integration" "integration/*")
(:exclude ".dir-locals.el" "*-tests.el")))) (:exclude ".dir-locals.el" "*-tests.el"))))
#+end_src #+end_src
Fix the issue that backspace doesn't work on mac Fix the issue that backspace doesn't work on mac
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(after! eat (after! eat
(when (eq system-type 'darwin) (when (eq system-type 'darwin)
(define-key eat-semi-char-mode-map (kbd "C-h") #'eat-self-input) (define-key eat-semi-char-mode-map (kbd "C-h") #'eat-self-input)
(define-key eat-semi-char-mode-map (kbd "<backspace>") (kbd "C-h")))) (define-key eat-semi-char-mode-map (kbd "<backspace>") (kbd "C-h"))))
#+end_src #+end_src
*** Copilot *** Copilot
#+begin_src emacs-lisp :tangle packages.el #+begin_src emacs-lisp :tangle packages.el
(package! copilot (package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))) :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
#+end_src #+end_src
Configuration Configuration
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; accept completion from copilot and fallback to company ;; accept completion from copilot and fallback to company
(use-package! copilot (use-package! copilot
:hook (prog-mode . copilot-mode) :hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map :bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion) ("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion) ("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word) ("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word) ("C-<tab>" . 'copilot-accept-completion-by-word)
("C-n" . 'copilot-next-completion) ("C-n" . 'copilot-next-completion)
("C-p" . 'copilot-previous-completion)) ("C-p" . 'copilot-previous-completion))
:config :config
(add-to-list 'copilot-indentation-alist '(prog-mode 2)) (add-to-list 'copilot-indentation-alist '(prog-mode 2))
(add-to-list 'copilot-indentation-alist '(org-mode 2)) (add-to-list 'copilot-indentation-alist '(org-mode 2))
(add-to-list 'copilot-indentation-alist '(text-mode 2)) (add-to-list 'copilot-indentation-alist '(text-mode 2))
(add-to-list 'copilot-indentation-alist '(clojure-mode 2)) (add-to-list 'copilot-indentation-alist '(clojure-mode 2))
(add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2)))
#+end_src #+end_src
** Lang ** Lang
@@ -89,47 +91,51 @@ Configuration
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package! typst-ts-mode (use-package! typst-ts-mode
:custom :init
;; (typst-ts-watch-options "--open") (add-hook 'typst-ts-mode-hook #'eglot-ensure)
(typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) :custom
(typst-ts-mode-enable-raw-blocks-highlight t) ;; (typst-ts-watch-options "--open")
:config (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory))
(keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu)) (typst-ts-mode-enable-raw-blocks-highlight t)
:config
(keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu))
#+end_src #+end_src
**** Tinymist (lsp) **** Tinymist (lsp)
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'eglot (with-eval-after-load 'eglot
(with-eval-after-load 'typst-ts-mode (with-eval-after-load 'typst-ts-mode
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
`((typst-ts-mode) . `((typst-ts-mode) .
,(eglot-alternatives `(,typst-ts-lsp-download-path ,(eglot-alternatives `(,"tinymist"
"tinymist" "typst-lsp"))))))
"typst-lsp"))))))
#+end_src #+end_src
**** Live-preview **** Live-preview
#+begin_src emacs-lisp :tangle packages.el #+begin_src emacs-lisp :tangle packages.el
(package! typst-preview (package! typst-preview
:recipe (:host github :repo "havarddj/typst-preview.el")) :recipe (:host github :repo "havarddj/typst-preview.el"))
#+end_src #+end_src
***** Config ***** Config
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package! websocket) (use-package! websocket)
(use-package! typst-preview (use-package! typst-preview
;; :load-path "path/to/typst-preview.el" ;; if installed manually ;; :load-path "path/to/typst-preview.el" ;; if installed manually
:init :init
(setq typst-preview-autostart t) ; start preview automatically when typst-preview-mode is activated (setq typst-preview-autostart t) ; start preview automatically when typst-preview-mode is activated
;; (setq typst-preview-open-browser-automatically t) ; open browser automatically when typst-preview-start is run ;; (setq typst-preview-open-browser-automatically t) ; open browser automatically when typst-preview-start is run
:custom :custom
(typst-preview-browser "default") ; this is the default option; other options are `eaf-browser' or `xwidget'. (typst-preview-browser "default") ; this is the default option; other options are `eaf-browser' or `xwidget'.
(typst-preview-invert-colors "auto") ; invert colors depending on system theme (typst-preview-invert-colors "auto") ; invert colors depending on system theme
(typst-preview-executable "tinymist") ; path to tinymist binary (relative or absolute) (typst-preview-executable "tinymist") ; path to tinymist binary (relative or absolute)
(typst-preview-partial-rendering t) ; enable partial rendering (typst-preview-partial-rendering t) ; enable partial rendering
:config :config
(define-key typst-preview-mode-map (kbd "C-c C-j") 'typst-preview-send-position) (define-key typst-preview-mode-map (kbd "C-c C-j") 'typst-preview-send-position)
(define-key typst-ts-mode-map (kbd "C-c C-l") #'typst-preview-mode)) (define-key typst-ts-mode-map (kbd "C-c C-l") #'typst-preview-mode))
#+end_src #+end_src
#+RESULTS:
: t

12
init.el
View File

@@ -21,11 +21,11 @@
;;layout ; auie,ctsrnm is the superior home row ;;layout ; auie,ctsrnm is the superior home row
:completion :completion
;;company ; the ultimate code completion backend ;;company ; the ultimate code completion backend
(corfu +orderless) ; complete with cap(f), cape and a flying feather! (corfu +icons +orderless) ; complete with cap(f), cape and a flying feather!
;;helm ; the *other* search engine for love and life ;;helm ; the *other* search engine for love and life
;;ido ; the other *other* search engine... ;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life ;;ivy ; a search engine for love and life
vertico ; the search engine of the future (vertico +icons + childframe) ; the search engine of the future
:ui :ui
;;deft ; notational velocity for Emacs ;;deft ; notational velocity for Emacs
@@ -56,10 +56,10 @@
(evil +everywhere); come to the dark side, we have cookies (evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding fold ; (nigh) universal code folding
;;(format +onsave) ; automated prettiness (format +onsave +lsp) ; automated prettiness
;;god ; run Emacs commands without modifier keys ;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim ;;lispy ; vim for lisp, for people who don't like vim
;;multiple-cursors ; editing in many places at once multiple-cursors ; editing in many places at once
;;objed ; text object editing for the innocent ;;objed ; text object editing for the innocent
;;parinfer ; turn lisp into python, sort of ;;parinfer ; turn lisp into python, sort of
;;rotate-text ; cycle region at point between text candidates ;;rotate-text ; cycle region at point between text candidates
@@ -99,7 +99,7 @@
(eval +overlay) ; run code, run (also, repls) (eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation lookup ; navigate your code and its documentation
;;llm ; when I said you needed friends, I didn't mean... ;;llm ; when I said you needed friends, I didn't mean...
(lsp +eglot +peek) ; M-x vscode (lsp +eglot +peek +booster) ; M-x vscode
magit ; a git porcelain for Emacs magit ; a git porcelain for Emacs
make ; run make tasks from Emacs make ; run make tasks from Emacs
;;pass ; password manager for nerds ;;pass ; password manager for nerds
@@ -148,7 +148,7 @@
;;javascript ; all(hope(abandon(ye(who(enter(here)))))) ;;javascript ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB ;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script) ;;kotlin ; a better, slicker Java(Script)
latex ; writing papers in Emacs has never been so fun (latex +cdlatex +lsp +fold) ; writing papers in Emacs has never been so fun
lean ; for folks with too much to prove lean ; for folks with too much to prove
;;ledger ; be audit you can be ;;ledger ; be audit you can be
;; lua ; one-based indices? one-based indices ;; lua ; one-based indices? one-based indices

View File

@@ -1,9 +1,9 @@
(package! catppuccin-theme) (package! catppuccin-theme)
(package! copilot (package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))) :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
(package! typst-ts-mode :recipe (:host codeberg :repo "meow_king/typst-ts-mode")) (package! typst-ts-mode :recipe (:host codeberg :repo "meow_king/typst-ts-mode"))
(package! typst-preview (package! typst-preview
:recipe (:host github :repo "havarddj/typst-preview.el")) :recipe (:host github :repo "havarddj/typst-preview.el"))

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: display math
# key: dm
# condition: (and (not (texmathp)) (quote auto))
# group: math
# --
\$ $0 \$

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: inline math
# key: mk
# condition: (and (not (texmathp)) (quote auto))
# group: math
# --
\$$0\$

View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: Theorem
# key: #thm
# condition: (and (not (texmathp)) (quote auto))
# group: math
# --
#theorem()[
$0
]