From 506025930b4e94297c78f1addd6ba590331df1c7 Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Sun, 16 Nov 2025 22:05:10 +1100 Subject: [PATCH] Update --- config.el | 97 ++++++++++---------- config.org | 134 +++++++++++++++------------- init.el | 12 +-- packages.el | 4 +- snippets/typst-ts-mode/display math | 7 ++ snippets/typst-ts-mode/inline math | 7 ++ snippets/typst-ts-mode/theorem | 9 ++ 7 files changed, 151 insertions(+), 119 deletions(-) create mode 100644 snippets/typst-ts-mode/display math create mode 100644 snippets/typst-ts-mode/inline math create mode 100644 snippets/typst-ts-mode/theorem diff --git a/config.el b/config.el index 17a33a0..1307bf4 100644 --- a/config.el +++ b/config.el @@ -1,67 +1,70 @@ +(setq-default tab-width 4) + (setq doom-font (font-spec :family "Maple Mono" :size 20)) (add-to-list 'default-frame-alist '(height . 53)) (add-to-list 'default-frame-alist '(width . 120)) +(setq catppuccin-flavor 'mocha) (setq doom-theme 'catppuccin) (setq display-line-numbers-type 'relative) (setq org-directory "~/org/") -(setq catppuccin-flavor 'mocha) -(catppuccin-reload) - -(after! yasnippet - (defun my-yas-try-expanding-auto-snippets () - (when yas-minor-mode - (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) - (yas-expand)))) - (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets)) +(use-package! yasnippet + :config + (defun my-yas-try-expanding-auto-snippets () + (when yas-minor-mode + (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) + (yas-expand)))) + (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets) +) ;; accept completion from copilot and fallback to company (use-package! copilot - :hook (prog-mode . copilot-mode) - :bind (:map copilot-completion-map - ("" . 'copilot-accept-completion) - ("TAB" . 'copilot-accept-completion) - ("C-TAB" . 'copilot-accept-completion-by-word) - ("C-" . 'copilot-accept-completion-by-word) - ("C-n" . 'copilot-next-completion) - ("C-p" . 'copilot-previous-completion)) + :hook (prog-mode . copilot-mode) + :bind (:map copilot-completion-map + ("" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-" . 'copilot-accept-completion-by-word) + ("C-n" . 'copilot-next-completion) + ("C-p" . 'copilot-previous-completion)) - :config - (add-to-list 'copilot-indentation-alist '(prog-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 '(clojure-mode 2)) - (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) + :config + (add-to-list 'copilot-indentation-alist '(prog-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 '(clojure-mode 2)) + (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) (use-package! typst-ts-mode - :custom - ;; (typst-ts-watch-options "--open") - (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) - (typst-ts-mode-enable-raw-blocks-highlight t) - :config - (keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu)) + :init + (add-hook 'typst-ts-mode-hook #'eglot-ensure) + :custom + ;; (typst-ts-watch-options "--open") + (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) + (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 'typst-ts-mode - (add-to-list 'eglot-server-programs - `((typst-ts-mode) . - ,(eglot-alternatives `(,typst-ts-lsp-download-path - "tinymist" - "typst-lsp")))))) + (with-eval-after-load 'typst-ts-mode + (add-to-list 'eglot-server-programs + `((typst-ts-mode) . + ,(eglot-alternatives `(,"tinymist" + "typst-lsp")))))) (use-package! websocket) (use-package! typst-preview - ;; :load-path "path/to/typst-preview.el" ;; if installed manually - :init - (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 + ;; :load-path "path/to/typst-preview.el" ;; if installed manually + :init + (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 - :custom - (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-executable "tinymist") ; path to tinymist binary (relative or absolute) - (typst-preview-partial-rendering t) ; enable partial rendering + :custom + (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-executable "tinymist") ; path to tinymist binary (relative or absolute) + (typst-preview-partial-rendering t) ; enable partial rendering - :config - (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)) + :config + (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)) diff --git a/config.org b/config.org index 28d1dce..5ab6701 100644 --- a/config.org +++ b/config.org @@ -1,83 +1,85 @@ * My doom config +** Some tweak +*** change indent size +#+begin_src emacs-lisp +(setq-default tab-width 4) +#+end_src ** Appearance settings #+begin_src emacs-lisp (setq doom-font (font-spec :family "Maple Mono" :size 20)) (add-to-list 'default-frame-alist '(height . 53)) (add-to-list 'default-frame-alist '(width . 120)) +(setq catppuccin-flavor 'mocha) (setq doom-theme 'catppuccin) (setq display-line-numbers-type 'relative) (setq org-directory "~/org/") #+end_src *** Themes -Catppuccin +**** Catppuccin #+begin_src emacs-lisp :tangle packages.el (package! catppuccin-theme) #+end_src - -#+begin_src emacs-lisp -(setq catppuccin-flavor 'mocha) -(catppuccin-reload) -#+end_src - ** Plugins *** Yasnippet This enables the feature of auto-expanding snippets when matching the pattern #+begin_src emacs-lisp -(after! yasnippet - (defun my-yas-try-expanding-auto-snippets () - (when yas-minor-mode - (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) - (yas-expand)))) - (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets)) +(use-package! yasnippet + :config + (defun my-yas-try-expanding-auto-snippets () + (when yas-minor-mode + (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) + (yas-expand)))) + (add-hook 'post-command-hook #'my-yas-try-expanding-auto-snippets) +) #+end_src *** Eat (deprecated) #+begin_src emacs-lisp :tangle no (package! eat - :recipe (:type git - :host codeberg - :repo "akib/emacs-eat" - :files ("*.el" ("term" "term/*.el") "*.texi" - "*.ti" ("terminfo/e" "terminfo/e/*") - ("terminfo/65" "terminfo/65/*") - ("integration" "integration/*") - (:exclude ".dir-locals.el" "*-tests.el")))) + :recipe (:type git + :host codeberg + :repo "akib/emacs-eat" + :files ("*.el" ("term" "term/*.el") "*.texi" + "*.ti" ("terminfo/e" "terminfo/e/*") + ("terminfo/65" "terminfo/65/*") + ("integration" "integration/*") + (:exclude ".dir-locals.el" "*-tests.el")))) #+end_src Fix the issue that backspace doesn't work on mac #+begin_src emacs-lisp :tangle no (after! eat - (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 "") (kbd "C-h")))) + (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 "") (kbd "C-h")))) #+end_src *** Copilot #+begin_src emacs-lisp :tangle packages.el (package! copilot - :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))) + :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))) #+end_src Configuration #+begin_src emacs-lisp ;; accept completion from copilot and fallback to company (use-package! copilot - :hook (prog-mode . copilot-mode) - :bind (:map copilot-completion-map - ("" . 'copilot-accept-completion) - ("TAB" . 'copilot-accept-completion) - ("C-TAB" . 'copilot-accept-completion-by-word) - ("C-" . 'copilot-accept-completion-by-word) - ("C-n" . 'copilot-next-completion) - ("C-p" . 'copilot-previous-completion)) + :hook (prog-mode . copilot-mode) + :bind (:map copilot-completion-map + ("" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-" . 'copilot-accept-completion-by-word) + ("C-n" . 'copilot-next-completion) + ("C-p" . 'copilot-previous-completion)) - :config - (add-to-list 'copilot-indentation-alist '(prog-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 '(clojure-mode 2)) - (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) + :config + (add-to-list 'copilot-indentation-alist '(prog-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 '(clojure-mode 2)) + (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) #+end_src ** Lang @@ -89,47 +91,51 @@ Configuration #+begin_src emacs-lisp (use-package! typst-ts-mode - :custom - ;; (typst-ts-watch-options "--open") - (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) - (typst-ts-mode-enable-raw-blocks-highlight t) - :config - (keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu)) + :init + (add-hook 'typst-ts-mode-hook #'eglot-ensure) + :custom + ;; (typst-ts-watch-options "--open") + (typst-ts-mode-grammar-location (expand-file-name "tree-sitter/libtree-sitter-typst.so" user-emacs-directory)) + (typst-ts-mode-enable-raw-blocks-highlight t) + :config + (keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu)) #+end_src **** Tinymist (lsp) #+begin_src emacs-lisp (with-eval-after-load 'eglot - (with-eval-after-load 'typst-ts-mode - (add-to-list 'eglot-server-programs - `((typst-ts-mode) . - ,(eglot-alternatives `(,typst-ts-lsp-download-path - "tinymist" - "typst-lsp")))))) + (with-eval-after-load 'typst-ts-mode + (add-to-list 'eglot-server-programs + `((typst-ts-mode) . + ,(eglot-alternatives `(,"tinymist" + "typst-lsp")))))) #+end_src **** Live-preview #+begin_src emacs-lisp :tangle packages.el (package! typst-preview - :recipe (:host github :repo "havarddj/typst-preview.el")) + :recipe (:host github :repo "havarddj/typst-preview.el")) #+end_src ***** Config #+begin_src emacs-lisp (use-package! websocket) (use-package! typst-preview - ;; :load-path "path/to/typst-preview.el" ;; if installed manually - :init - (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 + ;; :load-path "path/to/typst-preview.el" ;; if installed manually + :init + (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 - :custom - (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-executable "tinymist") ; path to tinymist binary (relative or absolute) - (typst-preview-partial-rendering t) ; enable partial rendering + :custom + (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-executable "tinymist") ; path to tinymist binary (relative or absolute) + (typst-preview-partial-rendering t) ; enable partial rendering - :config - (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)) + :config + (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)) #+end_src + +#+RESULTS: +: t diff --git a/init.el b/init.el index 6da9683..dc375ed 100644 --- a/init.el +++ b/init.el @@ -21,11 +21,11 @@ ;;layout ; auie,ctsrnm is the superior home row :completion ;;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 ;;ido ; the other *other* search engine... ;;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 ;;deft ; notational velocity for Emacs @@ -56,10 +56,10 @@ (evil +everywhere); come to the dark side, we have cookies file-templates ; auto-snippets for empty files fold ; (nigh) universal code folding - ;;(format +onsave) ; automated prettiness + (format +onsave +lsp) ; automated prettiness ;;god ; run Emacs commands without modifier keys ;;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 ;;parinfer ; turn lisp into python, sort of ;;rotate-text ; cycle region at point between text candidates @@ -99,7 +99,7 @@ (eval +overlay) ; run code, run (also, repls) lookup ; navigate your code and its documentation ;;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 make ; run make tasks from Emacs ;;pass ; password manager for nerds @@ -148,7 +148,7 @@ ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) ;;julia ; a better, faster MATLAB ;;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 ;;ledger ; be audit you can be ;; lua ; one-based indices? one-based indices diff --git a/packages.el b/packages.el index 5b2c29e..941d353 100644 --- a/packages.el +++ b/packages.el @@ -1,9 +1,9 @@ (package! catppuccin-theme) (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-preview - :recipe (:host github :repo "havarddj/typst-preview.el")) + :recipe (:host github :repo "havarddj/typst-preview.el")) diff --git a/snippets/typst-ts-mode/display math b/snippets/typst-ts-mode/display math new file mode 100644 index 0000000..f9f281d --- /dev/null +++ b/snippets/typst-ts-mode/display math @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: display math +# key: dm +# condition: (and (not (texmathp)) (quote auto)) +# group: math +# -- +\$ $0 \$ diff --git a/snippets/typst-ts-mode/inline math b/snippets/typst-ts-mode/inline math new file mode 100644 index 0000000..43f0631 --- /dev/null +++ b/snippets/typst-ts-mode/inline math @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: inline math +# key: mk +# condition: (and (not (texmathp)) (quote auto)) +# group: math +# -- +\$$0\$ \ No newline at end of file diff --git a/snippets/typst-ts-mode/theorem b/snippets/typst-ts-mode/theorem new file mode 100644 index 0000000..a59e1ea --- /dev/null +++ b/snippets/typst-ts-mode/theorem @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# name: Theorem +# key: #thm +# condition: (and (not (texmathp)) (quote auto)) +# group: math +# -- +#theorem()[ +$0 +] \ No newline at end of file