This commit is contained in:
Zelong Kuang
2026-04-03 00:22:19 +11:00
parent f2ec25c9d9
commit 204c683083
10 changed files with 142 additions and 150 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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-<mouse-1>" . mc/add-cursor-on-click)
("C-S-<mouse-1>" . 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-<mouse-1>" . mc/add-cursor-on-click)
;; ("C-S-<mouse-1>" . mc/add-cursor-on-click)
;; :map mc/keymap
;; ("C-|" . mc/vertical-align-with-space)))
(use-package expand-region
:bind ("C-=" . er/expand-region))

View File

@@ -81,13 +81,21 @@
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("'" . repeat)
'("<escape>" . ignore)))
'("<escape>" . 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 . "<N>")
(motion . "<M>")

View File

@@ -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)

View File

@@ -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")))

View File

@@ -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 ("<f5>" . doric-themes-load-random)
:bind ("C-<f5>" . (lambda () (interactive) (doric-themes-load-random 'light)))
:bind ("M-<f5>" . (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 ("<f5>" . doric-themes-load-random)
;; :bind ("C-<f5>" . (lambda () (interactive) (doric-themes-load-random 'light)))
;; :bind ("M-<f5>" . (lambda () (interactive) (doric-themes-load-random 'dark)))
:commands doric-themes-load-random)
(use-package ef-themes
:bind ("<f5>" . modus-themes-load-random)
:bind ("C-<f5>" . modus-themes-load-random-light)
:bind ("M-<f5>" . 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 <https://protesilaos.com/emacs/ef-themes#h:6585235a-5219-4f78-9dd5-6a64d87d1b6e>
(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)

View File

@@ -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