From b7832a60d1e857231bf8ea235be5ace3a0feedec Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Wed, 25 Feb 2026 22:12:47 +1100 Subject: [PATCH] Update --- early-init.el | 2 +- lisp/init-better-default.el | 10 +++- lisp/init-cc.el | 2 + lisp/init-edit.el | 72 ++++++++++++----------- lisp/init-eglot.el | 5 ++ lisp/init-elpaca.el | 4 +- lisp/init-gc.el | 1 + lisp/init-ui.el | 5 +- lisp/init-utils.el | 8 +-- lisp/init-workspace.el | 110 ++++++++++++++++++------------------ 10 files changed, 121 insertions(+), 98 deletions(-) diff --git a/early-init.el b/early-init.el index 2a22671..2a95422 100644 --- a/early-init.el +++ b/early-init.el @@ -36,6 +36,6 @@ ;; (push '(ns-appearance . dark) default-frame-alist)) ;; Prevent flash of unstyled mode line -(setq mode-line-format nil) +;; (setq mode-line-format nil) (provide 'early-init) diff --git a/lisp/init-better-default.el b/lisp/init-better-default.el index 5d25fd9..307e064 100644 --- a/lisp/init-better-default.el +++ b/lisp/init-better-default.el @@ -65,9 +65,10 @@ (pcase system-type ('darwin (setq insert-directory-program "gls"))) -(setq-default tab-width 4 - compilation-scroll-output t - indent-tabs-mode nil) +(setq-default tab-width 2 + standard-indent 2 + compilation-scroll-output t + indent-tabs-mode nil) (setq ring-bell-function 'ignore) (setq undo-limit 80000000 @@ -128,7 +129,10 @@ (lambda (button) (helpful-variable (button-get button 'apropos-symbol)))))))) +(setq auto-save-default nil) ;; (setq auto-save-file-name-transforms ;; `((".*" ,(concat user-emacs-directory "auto-save/") t))) + + (provide 'init-better-default) diff --git a/lisp/init-cc.el b/lisp/init-cc.el index 79aadcf..f888374 100644 --- a/lisp/init-cc.el +++ b/lisp/init-cc.el @@ -4,12 +4,14 @@ :ensure nil :init (setq-default c-basic-offset 2)) + (when (treesit-available-p) (use-package c-ts-mode :ensure nil :functions treesit-available-p :init (setq c-ts-mode-indent-offset 2) + (setq-default c-basic-offset 2) (when (boundp 'major-mode-remap-alist) (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) diff --git a/lisp/init-edit.el b/lisp/init-edit.el index 1019b42..6b1da6d 100644 --- a/lisp/init-edit.el +++ b/lisp/init-edit.el @@ -1,37 +1,40 @@ ;; -*- lexical-binding: t -*- -;; (use-package smartparens -;; :hook (elpaca-after-init . smartparens-global-mode) -;; ;; :hook (elpaca-after-init . smartparens-global-strict-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 smartparens + :diminish + :hook (elpaca-after-init . smartparens-global-mode) + ;; :hook (elpaca-after-init . smartparens-global-strict-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))) -;; (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + (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"))) -;; ) + ;; 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"))) + + ;; resolve conflict with hungry-delete + (defadvice hungry-delete-backward (before sp-delete-pair-advice activate) (save-match-data (sp-delete-pair (ad-get-arg 0))))) -(use-package electric-pair - :ensure nil - :hook elpaca-after-init) +;; (use-package electric-pair +;; :ensure nil +;; :hook elpaca-after-init) ;; Hungry deletion (use-package hungry-delete @@ -43,6 +46,7 @@ ;; Yasnippet settings (use-package yasnippet + :diminish :ensure t :hook (elpaca-after-init . yas-global-mode) :hook ((LaTeX-mode . yas-minor-mode) @@ -65,13 +69,17 @@ (let ((yas-buffer-local-condition ''(require-snippet-condition . auto))) (yas-expand))))) -(setq-default abbrev-mode t) -(setq abbrev-file-name (expand-file-name "abbrev.el" user-emacs-directory)) +(use-package abbrev + :diminish + :ensure nil + :config + (setq-default abbrev-mode t) + (setq abbrev-file-name (expand-file-name "abbrev.el" user-emacs-directory))) (use-package autorevert :ensure nil :diminish - :hook (after-init . global-auto-revert-mode)) + :hook (elpaca-after-init . global-auto-revert-mode)) (use-package multiple-cursors :hook elpaca-after-init diff --git a/lisp/init-eglot.el b/lisp/init-eglot.el index 94777a4..fc26f21 100644 --- a/lisp/init-eglot.el +++ b/lisp/init-eglot.el @@ -37,7 +37,12 @@ ;; (use-package eldoc-box ;; :hook (eglot-managed-mode . eldoc-box-hover-at-point-mode)) +(use-package eldoc + :ensure nil + :diminish) + (use-package eldoc-mouse + :diminish :hook eldoc-mode) (provide 'init-eglot) diff --git a/lisp/init-elpaca.el b/lisp/init-elpaca.el index e3b8c64..2df8ea9 100644 --- a/lisp/init-elpaca.el +++ b/lisp/init-elpaca.el @@ -56,11 +56,13 @@ ;;For example: ;;(use-package general :ensure (:wait t) :demand t) +(setq elpaca-lock-file (expand-file-name "lock-file.eld" user-emacs-directory)) + (setq use-package-always-ensure t use-package-expand-minimally t use-package-always-defer t) - +(use-package diminish) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/lisp/init-gc.el b/lisp/init-gc.el index 99f93c2..4c55ef3 100644 --- a/lisp/init-gc.el +++ b/lisp/init-gc.el @@ -2,6 +2,7 @@ (use-package gcmh + :diminish :init (gcmh-mode 1) :config diff --git a/lisp/init-ui.el b/lisp/init-ui.el index 3882a9c..6470378 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -77,8 +77,8 @@ ;; (setq doom-modeline-support-imenu t ;; doom-modeline-height 30 ;; doom-modeline-bar-width 8)) -(use-package minions - :hook elpaca-after-init) +;; (use-package minions +;; :hook elpaca-after-init) (use-package hide-mode-line :autoload turn-off-hide-mode-line-mode @@ -161,6 +161,7 @@ :hook (ibuffer-mode-hook . nerd-icons-ibuffer-mode)) (use-package beacon + :diminish :hook elpaca-after-init) (use-package spacious-padding) diff --git a/lisp/init-utils.el b/lisp/init-utils.el index 6305066..c39cbae 100644 --- a/lisp/init-utils.el +++ b/lisp/init-utils.el @@ -36,9 +36,9 @@ :config (pdf-tools-install)) -(use-package keycast - :hook (elpaca-after-init . keycast-tab-bar-mode) - :config - (setq keycast-mode-line-remove-tail-elements nil)) +;; (use-package keycast +;; :hook (elpaca-after-init . keycast-mode-line-mode) +;; :config +;; (setq keycast-mode-line-remove-tail-elements nil)) (provide 'init-utils) diff --git a/lisp/init-workspace.el b/lisp/init-workspace.el index d88e160..847b00a 100644 --- a/lisp/init-workspace.el +++ b/lisp/init-workspace.el @@ -3,67 +3,67 @@ (use-package project) -(use-package tab-bar - :ensure nil - :init - (tab-bar-mode t) - (setq tab-bar-new-tab-choice "*scratch*") ;; buffer to show in new tabs - (setq tab-bar-close-button-show nil) ;; hide tab close / X button - (setq tab-bar-show 1) ;; hide bar if <= 1 tabs open - (setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator)) +;; (use-package tab-bar +;; :ensure nil +;; :init +;; (tab-bar-mode t) +;; (setq tab-bar-new-tab-choice "*scratch*") ;; buffer to show in new tabs +;; (setq tab-bar-close-button-show nil) ;; hide tab close / X button +;; (setq tab-bar-show t) ;; hide bar if <= 1 tabs open +;; (setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator)) - (setq tab-bar-tab-hints t)) +;; (setq tab-bar-tab-hints t)) (global-set-key (kbd "C-x C-b") #'ibuffer) -(use-package tabspaces - :functions tabspaces-mode - :commands (tabspaces-switch-or-create-workspace - tabspaces-open-or-create-project-and-workspace) - :hook (elpaca-after-init . tabspaces-mode) - :bind (:map tabspaces-mode-map - ([remap project-switch-project] . tabspaces-project-switch-project-open-file)) - :bind (:map tabspaces-command-map - ("l" . tabspaces-restore-session) - ("s" . tabspaces-save-session) - ("TAB" . tabspaces-switch-or-create-workspace)) +;; (use-package tabspaces +;; :functions tabspaces-mode +;; :commands (tabspaces-switch-or-create-workspace +;; tabspaces-open-or-create-project-and-workspace) +;; :hook (elpaca-after-init . tabspaces-mode) +;; :bind (:map tabspaces-mode-map +;; ([remap project-switch-project] . tabspaces-project-switch-project-open-file)) +;; :bind (:map tabspaces-command-map +;; ("l" . tabspaces-restore-session) +;; ("s" . tabspaces-save-session) +;; ("TAB" . tabspaces-switch-or-create-workspace)) - :custom - (tabspaces-use-filtered-buffers-as-default t) - (tabspaces-default-tab "Default") - (tabspaces-remove-to-default t) - (tabspaces-include-buffers '("*scratch*" "*Messages*")) - (tabspaces-exclude-buffers '("*eat*" "*vterm*" "*shell*" "*eshell*")) - ;; sessions - (tabspaces-session t) - ;; (tabspaces-session-auto-restore t) - (tabspaces-keymap-prefix "C-c o") - (tab-bar-new-tab-choice "default") +;; :custom +;; (tabspaces-use-filtered-buffers-as-default t) +;; (tabspaces-default-tab "Default") +;; (tabspaces-remove-to-default t) +;; (tabspaces-include-buffers '("*scratch*" "*Messages*")) +;; (tabspaces-exclude-buffers '("*eat*" "*vterm*" "*shell*" "*eshell*")) +;; ;; sessions +;; (tabspaces-session t) +;; (tabspaces-session-auto-restore t) +;; (tabspaces-keymap-prefix "C-c o") +;; (tab-bar-new-tab-choice "default") - (with-eval-after-load 'consult - ;; hide full buffer list (still available with "b" prefix) - (consult-customize consult--source-buffer :hidden nil :default nil) - ;; set consult-workspace buffer list - (defvar consult--source-workspace - (list :name "Workspace Buffers" - :narrow ?w - :history 'buffer-name-history - :category 'buffer - :state #'consult--buffer-state - :default t - :items (lambda () (consult--buffer-query - :predicate #'tabspaces--local-buffer-p - :sort 'visibility - :as #'buffer-name))) +;; (with-eval-after-load 'consult +;; ;; hide full buffer list (still available with "b" prefix) +;; (consult-customize consult--source-buffer :hidden nil :default nil) +;; ;; set consult-workspace buffer list +;; (defvar consult--source-workspace +;; (list :name "Workspace Buffers" +;; :narrow ?w +;; :history 'buffer-name-history +;; :category 'buffer +;; :state #'consult--buffer-state +;; :default t +;; :items (lambda () (consult--buffer-query +;; :predicate #'tabspaces--local-buffer-p +;; :sort 'visibility +;; :as #'buffer-name))) - "Set workspace buffer list for consult-buffer.") - (add-to-list 'consult-buffer-sources 'consult--source-workspace))) - -;; (use-package beframe -;; :hook elpaca-after-init -;; :bind (("C-x b" . beframe-switch-buffer) -;; ("C-x C-b" . beframe-buffer-menu)) -;; :config -;; (setq beframe-functions-in-frames '(project-prompt-project-dir))) +;; "Set workspace buffer list for consult-buffer.") +;; (add-to-list 'consult-buffer-sources 'consult--source-workspace))) + +(use-package beframe + :hook elpaca-after-init + :bind (("C-x b" . beframe-switch-buffer) + ("C-x C-b" . beframe-buffer-menu))) + ;; :config + ;; (setq beframe-functions-in-frames '(project-prompt-project-dir))) (provide 'init-workspace)