diff --git a/init.el b/init.el index 0c78021..9e06acb 100644 --- a/init.el +++ b/init.el @@ -37,7 +37,7 @@ (require 'init-workspace) ;; (require 'init-god) -;; (require 'init-meow) +(require 'init-meow) (require 'init-input) (require 'init-utils) diff --git a/lisp/init-better-default.el b/lisp/init-better-default.el index d8b66f6..1de1d83 100644 --- a/lisp/init-better-default.el +++ b/lisp/init-better-default.el @@ -118,16 +118,16 @@ If this is a daemon session, load them all immediately instead." (setq display-line-numbers-type 'relative) ) -(use-package del-trailing-white - :ensure nil - :hook ((prog-mode markdown-mode conf-mode) . enable-trailing-whitespace) - :init - (setq-default show-trailing-whitespace nil) - (defun enable-trailing-whitespace () - "Show trailing spaces and delete on saving." - (setq show-trailing-whitespace t) - (add-hook 'before-save-hook #'delete-trailing-whitespace nil t)) - ) +;; (use-package del-trailing-white +;; :ensure nil +;; :hook ((prog-mode markdown-mode conf-mode) . enable-trailing-whitespace) +;; :init +;; (setq-default show-trailing-whitespace nil) +;; (defun enable-trailing-whitespace () +;; "Show trailing spaces and delete on saving." +;; (setq show-trailing-whitespace t) +;; (add-hook 'before-save-hook #'delete-trailing-whitespace nil t)) +;; ) (use-package subword :ensure nil diff --git a/lisp/init-completion.el b/lisp/init-completion.el index 9c6d6a2..1b5b93b 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -250,12 +250,11 @@ ;;Quit completion before saving (add-hook 'before-save-hook #'corfu-quit) (advice-add #'persistent-scratch-save :before #'corfu-quit) - (add-to-list 'corfu-continue-commands #'corfu-move-to-minibuffer)) + (add-to-list 'corfu-continue-commands #'corfu-move-to-minibuffer) + (use-package nerd-icons-corfu + :init + (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))) -;; (use-package nerd-icons-corfu -;; :init -;; (with-eval-after-load 'corfu -;; (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))) ;; A few more useful configurations... (use-package emacs diff --git a/lisp/init-edit.el b/lisp/init-edit.el index e5843b8..1b9c07e 100644 --- a/lisp/init-edit.el +++ b/lisp/init-edit.el @@ -4,42 +4,46 @@ :ensure nil :hook (elpaca-after-init . delete-selection-mode)) -(use-package smartparens - :diminish - :hook (elpaca-after-init . smartparens-global-mode) - :init (sp-use-paredit-bindings) - :config - ;; Autopair quotes more conservatively; if I'm next to a word/before another - ;; quote, I don't want to open a new pair or it would unbalance them. - (let ((unless-list '(sp-point-before-word-p - sp-point-after-word-p - sp-point-before-same-p))) - (sp-pair "'" nil :unless unless-list) - (sp-pair "\"" nil :unless unless-list)) - (dolist (brace '("(" "{" "[")) - (sp-pair brace nil - :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) - ;; Don't autopair opening braces if before a word character or - ;; other opening brace. The rationale: it interferes with manual - ;; balancing of braces, and is odd form to have s-exps with no - ;; whitespace in between, e.g. ()()(). Insert whitespace if - ;; genuinely want to start a new form in the middle of a word. - :unless '(sp-point-before-word-p sp-point-before-same-p))) +(use-package electric-pair-mode + :ensure nil + :hook elpaca-after-init) - (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) +;; (use-package smartparens +;; :diminish +;; :hook (elpaca-after-init . smartparens-global-mode) +;; :init (sp-use-paredit-bindings) +;; :config +;; ;; Autopair quotes more conservatively; if I'm next to a word/before another +;; ;; quote, I don't want to open a new pair or it would unbalance them. +;; (let ((unless-list '(sp-point-before-word-p +;; sp-point-after-word-p +;; sp-point-before-same-p))) +;; (sp-pair "'" nil :unless unless-list) +;; (sp-pair "\"" nil :unless unless-list)) +;; (dolist (brace '("(" "{" "[")) +;; (sp-pair brace nil +;; :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) +;; ;; Don't autopair opening braces if before a word character or +;; ;; other opening brace. The rationale: it interferes with manual +;; ;; balancing of braces, and is odd form to have s-exps with no +;; ;; whitespace in between, e.g. ()()(). Insert whitespace if +;; ;; genuinely want to start a new form in the middle of a word. +;; :unless '(sp-point-before-word-p sp-point-before-same-p))) - ;; Don't do square-bracket space-expansion where it doesn't make sense to - (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode markdown-ts-mode gfm-mode) - "[" nil :post-handlers '(:rem ("| " "SPC")))) +;; (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + +;; ;; Don't do square-bracket space-expansion where it doesn't make sense to +;; (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode markdown-ts-mode gfm-mode) +;; "[" nil :post-handlers '(:rem ("| " "SPC")))) ;; ;; Hungry deletion -;; (use-package hungry-delete -;; :diminish -;; :hook (elpaca-after-init . global-hungry-delete-mode) -;; :init (setq hungry-delete-chars-to-skip " \t\f\v" -;; hungry-delete-except-modes -;; '(help-mode minibuffer-mode minibuffer-inactive-mode calc-mode))) +(use-package hungry-delete + :diminish + :hook (elpaca-after-init . global-hungry-delete-mode) + :init (setq hungry-delete-chars-to-skip " \t\f\v" + hungry-delete-except-modes + '(help-mode minibuffer-mode minibuffer-inactive-mode calc-mode))) (use-package abbrev :ensure nil @@ -58,18 +62,18 @@ :hook ((text-mode . goto-address-mode) (prog-mode . goto-address-prog-mode))) -(use-package multiple-cursors - :hook prog-mode - :bind (("C-S-c C-S-c" . mc/edit-lines) - ("C->" . mc/mark-next-like-this) - ("C-<" . mc/mark-previous-like-this) - ("C-c C-<" . mc/mark-all-like-this) - ("C-M->" . mc/skip-to-next-like-this) - ("C-M-<" . mc/skip-to-previous-like-this) - ("s-" . mc/add-cursor-on-click) - ("C-S-" . mc/add-cursor-on-click) - :map mc/keymap - ("C-|" . mc/vertical-align-with-space))) +;; (use-package multiple-cursors +;; :hook prog-mode +;; :bind (("C-S-c C-S-c" . mc/edit-lines) +;; ("C->" . mc/mark-next-like-this) +;; ("C-<" . mc/mark-previous-like-this) +;; ("C-c C-<" . mc/mark-all-like-this) +;; ("C-M->" . mc/skip-to-next-like-this) +;; ("C-M-<" . mc/skip-to-previous-like-this) +;; ("s-" . mc/add-cursor-on-click) +;; ("C-S-" . mc/add-cursor-on-click) +;; :map mc/keymap +;; ("C-|" . mc/vertical-align-with-space))) (use-package expand-region :bind ("C-=" . er/expand-region)) diff --git a/lisp/init-meow.el b/lisp/init-meow.el index 7ca3e6c..44ccdb3 100644 --- a/lisp/init-meow.el +++ b/lisp/init-meow.el @@ -81,13 +81,21 @@ '("Y" . meow-sync-grab) '("z" . meow-pop-selection) '("'" . repeat) - '("" . ignore))) + '("" . ignore)) + (meow-define-keys + 'beacon + '("C-g" . meow-grab)) + ) (use-package meow :demand t :hook (elpaca-after-init . meow-global-mode) :config (meow-setup) + (add-to-list 'meow-mode-state-list '((magit-mode . insert))) + (setq meow-keypad-leader-dispatch "C-c" + meow-cursor-type-normal 'hbar + meow-use-clipboard t) (setq meow-replace-state-name-list '((normal . "") (motion . "") diff --git a/lisp/init-org.el b/lisp/init-org.el index b31cce3..c3095bf 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -6,32 +6,9 @@ ;; "* TODO %?\n%i\n%a" :prepend t)))) (use-package org - :ensure (org (:repo "https://code.tecosaur.net/tec/org-mode.git" - :branch "dev")) - ;; :ensure (org :fork (:host nil - ;; :repo "https://code.tecosaur.net/tec/org-mode.git" - ;; :branch "dev") - ;; :remote "tecosaur") - ;; :branch "dev" - ;; :files (:defaults "etc") - ;; :build t - ;; :pre-build - ;; (with-temp-file "org-version.el" - ;; (require 'lisp-mnt) - ;; (let ((version - ;; (with-temp-buffer - ;; (insert-file-contents "lisp/org.el") - ;; (lm-header "version"))) - ;; (git-version - ;; (string-trim - ;; (with-temp-buffer - ;; (call-process "git" nil t nil "rev-parse" "--short" "HEAD") - ;; (buffer-string))))) - ;; (insert - ;; (format "(defun org-release () \"The release version of Org.\" %S)\n" version) - ;; (format "(defun org-git-version () \"The truncate git commit hash of Org mode.\" %S)\n" git-version) - ;; "(provide 'org-version)\n"))) - ;; :pin nil) + :defer + :ensure (org :repo "https://code.tecosaur.net/tec/org-mode.git/" + :branch "dev") :hook (org-mode . org-cdlatex-mode) :hook (org-mode . org-indent-mode) :hook (org-mode . visual-line-mode) @@ -143,7 +120,43 @@ the element after the #+HEADER: tag." (add-hook 'org-after-refile-insert-hook (defun save-buffer-after-capture () (when (bound-and-true-p org-capture-is-refiling) - (save-buffer))))) + (save-buffer)))) + + ;; ;; Enable lsp in org-babel + ;; (cl-defmacro lsp-org-babel-enable (lang) + ;; "Support LANG in org source code block." + ;; (cl-check-type lang string) + ;; (let* ((edit-pre (intern (format "org-babel-edit-prep:%s" lang))) + ;; (intern-pre (intern (format "lsp--%s" (symbol-name edit-pre))))) + ;; `(progn + ;; (defun ,intern-pre (info) + ;; (setq buffer-file-name (or (->> info caddr (alist-get :file)) + ;; "org-src-babel.tmp")) + ;; (when (fboundp 'lsp-deferred) + ;; ;; Avoid headerline conflicts + ;; (setq-local lsp-headerline-breadcrumb-enable nil) + ;; (lsp-deferred) + ;; (_ + ;; (user-error "LSP:: invalid type")))) + ;; (put ',intern-pre 'function-documentation + ;; (format "Enable lsp-mode in the buffer of org source block (%s)." + ;; (upcase ,lang))) + + ;; (if (fboundp ',edit-pre) + ;; (advice-add ',edit-pre :after ',intern-pre) + ;; (progn + ;; (defun ,edit-pre (info) + ;; (,intern-pre info)) + ;; (put ',edit-pre 'function-documentation + ;; (format "Prepare local buffer environment for org source block (%s)." + ;; (upcase ,lang)))))))) + + ;; (defconst org-babel-lang-list + ;; '("go" "python" "ipython" "ruby" "js" "css" "sass" "c" "rust" "java" "cpp" "c++" "shell") + ;; "The supported programming languages for interactive Babel.") + ;; (dolist (lang org-babel-lang-list) + ;; (eval `(lsp-org-babel-enable ,lang))) + ) (use-package org-contrib) @@ -328,39 +341,4 @@ the element after the #+HEADER: tag." (use-package djvu) (use-package org-noter) -;; Enable lsp in org-babel -(cl-defmacro lsp-org-babel-enable (lang) - "Support LANG in org source code block." - (cl-check-type lang string) - (let* ((edit-pre (intern (format "org-babel-edit-prep:%s" lang))) - (intern-pre (intern (format "lsp--%s" (symbol-name edit-pre))))) - `(progn - (defun ,intern-pre (info) - (setq buffer-file-name (or (->> info caddr (alist-get :file)) - "org-src-babel.tmp")) - (when (fboundp 'lsp-deferred) - ;; Avoid headerline conflicts - (setq-local lsp-headerline-breadcrumb-enable nil) - (lsp-deferred) - (_ - (user-error "LSP:: invalid type")))) - (put ',intern-pre 'function-documentation - (format "Enable lsp-mode in the buffer of org source block (%s)." - (upcase ,lang))) - - (if (fboundp ',edit-pre) - (advice-add ',edit-pre :after ',intern-pre) - (progn - (defun ,edit-pre (info) - (,intern-pre info)) - (put ',edit-pre 'function-documentation - (format "Prepare local buffer environment for org source block (%s)." - (upcase ,lang)))))))) - -(defconst org-babel-lang-list - '("go" "python" "ipython" "ruby" "js" "css" "sass" "c" "rust" "java" "cpp" "c++" "shell") - "The supported programming languages for interactive Babel.") -(dolist (lang org-babel-lang-list) - (eval `(lsp-org-babel-enable ,lang))) - (provide 'init-org) diff --git a/lisp/init-tex.el b/lisp/init-tex.el index 279fd14..a6b380a 100644 --- a/lisp/init-tex.el +++ b/lisp/init-tex.el @@ -41,9 +41,6 @@ (TeX-show-compilation nil) (TeX-command-extra-options "-shell-escape") (TeX-view-program-selection '((output-pdf "displayline"))) - (LaTeX-indent-level 0) - (LaTeX-item-indent 0) - (TeX-newline-function 'newline) :config (add-hook 'LaTeX-mode-hook '(lambda () (setq TeX-command-default "LaTeXMk"))) diff --git a/lisp/init-ui.el b/lisp/init-ui.el index 1aaf780..addb3e4 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -25,28 +25,32 @@ :init (setq modus-themes-italic-constructs t modus-themes-bold-constructs t - modus-themes-mixed-fonts t)) + modus-themes-mixed-fonts t) + :commands (modus-themes-load-random-dark + modus-themes-load-random-light + modus-themes-load-random)) -;; (use-package standard-themes :demand t -;; :config -;; (modus-themes-load-theme 'standard-light-tinted)) - -;; fix this (use-package doric-themes - :bind ("" . doric-themes-load-random) - :bind ("C-" . (lambda () (interactive) (doric-themes-load-random 'light))) - :bind ("M-" . (lambda () (interactive) (doric-themes-load-random 'dark))) - :commands doric-themes-load-random - ;; :init - ;; (defun synchronise-theme () - ;; (let* ((hour (string-to-number - ;; (substring (current-time-string) 11 13)))) - ;; (if (member hour (number-sequence 6 18)) - ;; (doric-themes-load-random 'light) - ;; (doric-themes-load-random 'dark)))) - ;; (synchronise-theme) - ;; (run-with-timer 3600 3600 'synchronise-theme) - ) + ;; :bind ("" . doric-themes-load-random) + ;; :bind ("C-" . (lambda () (interactive) (doric-themes-load-random 'light))) + ;; :bind ("M-" . (lambda () (interactive) (doric-themes-load-random 'dark))) + :commands doric-themes-load-random) + +(use-package ef-themes + :bind ("" . modus-themes-load-random) + :bind ("C-" . modus-themes-load-random-light) + :bind ("M-" . modus-themes-load-random-dark) + + :init + ;; This makes the Modus commands listed below consider only the Ef + ;; themes. For an alternative that includes Modus and all + ;; derivative themes (like Ef), enable the + ;; `modus-themes-include-derivatives-mode' instead. The manual of + ;; the Ef themes has a section that explains all the possibilities: + ;; + ;; - Evaluate `(info "(ef-themes) Working with other Modus themes or taking over Modus")' + ;; - Visit + (ef-themes-take-over-modus-themes-mode 1)) (use-package auto-dark :ensure t @@ -58,12 +62,14 @@ (auto-dark-dark-mode . (lambda () ;; something to execute when dark mode is detected - (doric-themes-load-random 'dark)) - ) + ;; (doric-themes-load-random 'dark)) + (modus-themes-load-random-dark) + )) (auto-dark-light-mode . (lambda () ;; something to execute when light mode is detected - (doric-themes-load-random 'light) + ;; (doric-themes-load-random 'light) + (modus-themes-load-random-light) )) :hook elpaca-after-init) diff --git a/lisp/init-workspace.el b/lisp/init-workspace.el index f18fe35..9d2a7bc 100644 --- a/lisp/init-workspace.el +++ b/lisp/init-workspace.el @@ -8,7 +8,7 @@ ;; Recommended keymap prefix on macOS (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) ;; Recommended keymap prefix on Windows/Linux - (define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)) (use-package ibuffer :ensure nil diff --git a/snippets/latex-mode/int.yasnippet b/snippets/latex-mode/int.yasnippet index d38a38e..95fe810 100644 --- a/snippets/latex-mode/int.yasnippet +++ b/snippets/latex-mode/int.yasnippet @@ -1,6 +1,6 @@ # -*- mode: snippet -*- # contributor: Song Qiang -# key: integ +# key: int # group: math # condition: (and (texmathp) 'auto) # name: Indefinite integral (all)