diff --git a/custom.el b/custom.el index 8b78fda..e69de29 100644 --- a/custom.el +++ b/custom.el @@ -1,33 +0,0 @@ -;;; -*- lexical-binding: t -*- -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(custom-safe-themes - '("7fea145741b3ca719ae45e6533ad1f49b2a43bf199d9afaee5b6135fd9e6f9b8" - default)) - '(package-selected-packages - '(ace-window benchmark-init cape cnfonts corfu crux drag-stuff eglot - embark-consult everything exec-path-form-shell gcmh - hungry-delete marginalia multiple-cursors orderless - restart-emacs smart-mode-line solarized-theme vertico)) - '(safe-local-variable-values - '((eval read-only-mode t) (eval jinx-mode nil) - (eval visual-line-mode nil) - (eval when (fboundp 'rainbow-mode) (rainbow-mode 1)) - (gptel-mode . t) - (eval progn - (setq org-hugo-base-dir - (if (eq system-type 'windows-nt) - "h:/emacs/hugo/this-is-my-blog/" - "~/org/hugo/this-is-my-blog/")) - (org-hugo-auto-export-mode)) - (org-use-tag-inheritance))) - '(warning-suppress-log-types '((initialization)))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) diff --git a/early-init.el b/early-init.el index aa9856d..8174c00 100644 --- a/early-init.el +++ b/early-init.el @@ -15,11 +15,6 @@ (setq display-line-numbers-grow-only t) ; 行号栏只增不减 (setq display-line-numbers-width-start 4) ; 预设4位宽度 -;; 启动时初始窗口最大化 -(add-to-list 'initial-frame-alist '(fullscreen . maximized)) -;; 之后新建的窗口也默认最大化 -(add-to-list 'default-frame-alist '(fullscreen . maximized)) - (setq frame-background-mode 'dark) (setq package-enable-at-startup nil) diff --git a/init.el b/init.el index 4647be6..6c4762a 100644 --- a/init.el +++ b/init.el @@ -13,9 +13,10 @@ (when (file-exists-p custom-file) (load-file custom-file)) -(if (display-graphic-p) +(require 'init-const) + +(if (or (display-graphic-p) *is-android*) (progn - (require 'init-const) (load "init-proxy" t) (require 'init-startup) (require 'init-elpa) diff --git a/lisp/init-completion.el b/lisp/init-completion.el index f547068..b5c30ec 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -24,36 +24,41 @@ completion-at-point-functions)))))) ;; corfu -(use-package corfu - :autoload - (corfu-quit consult-completion-in-region) - :functions - (persistent-scratch-save) - :custom - (corfu-auto t) - (corfu-auto-prefix 2) - (corfu-count 12) - (corfu-preview-current nil) - (corfu-on-exact-match nil) - (corfu-auto-delay 0.2) - (corfu-popupinfo-delay '(0.4 . 0.2)) - (global-corfu-modes '((not erc-mode - circe-mode - help-mode - gud-mode - vterm-mode) - t)) - :init - (global-corfu-mode) - (corfu-popupinfo-mode) - (corfu-history-mode) - :config - ;;Quit completion before saving - (add-hook 'before-save-hook #'corfu-quit) - (advice-add #'persistent-scratch-save :before #'corfu-quit) - :bind - (:map corfu-map - ("RET" . nil))) +(if (display-graphic-p) + (use-package corfu + :autoload + (corfu-quit consult-completion-in-region) + :functions + (persistent-scratch-save) + :custom + (corfu-auto t) + (corfu-auto-prefix 2) + (corfu-count 12) + (corfu-preview-current nil) + (corfu-on-exact-match nil) + (corfu-auto-delay 0.2) + (corfu-popupinfo-delay '(0.4 . 0.2)) + (global-corfu-modes '((not erc-mode + circe-mode + help-mode + gud-mode + vterm-mode) + t)) + :init + (global-corfu-mode) + (corfu-popupinfo-mode) + (corfu-history-mode) + :config + ;;Quit completion before saving + (add-hook 'before-save-hook #'corfu-quit) + (advice-add #'persistent-scratch-save :before #'corfu-quit) + :bind + (:map corfu-map + ("RET" . nil))) + + (use-package corfu-terminal + :init + (corfu-terminal-mode))) ;; 在eshell中使用tab打开补全 (add-hook 'eshell-mode-hook diff --git a/lisp/init-const.el b/lisp/init-const.el index e7ce84d..701448f 100644 --- a/lisp/init-const.el +++ b/lisp/init-const.el @@ -9,6 +9,7 @@ (defconst *is-linux* (eq system-type 'gnu/linux)) (defconst *is-windows* (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))) +(defconst *is-android* (if (getenv "TERMUX_VERSION") t nil)) (if *is-windows* (progn diff --git a/lisp/init-dired.el b/lisp/init-dired.el index 496f938..f5b61e2 100644 --- a/lisp/init-dired.el +++ b/lisp/init-dired.el @@ -6,6 +6,13 @@ (setq dired-dwim-target t) +(use-package dired + :straight nil + :config + (when *is-mac* + (setq insert-directory-program "gls") + (setq dired-use-ls-dired t))) + ;; dirvish (use-package dirvish :hook diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el index e9d9886..a88385c 100644 --- a/lisp/init-elpa.el +++ b/lisp/init-elpa.el @@ -45,7 +45,8 @@ (org-indent-mode nil org-indent) (desktop-environment-mode nil desktop-environment) (hs-minor-mode nil hideshow) - (god-local-mode ,(propertize " THANK-GOD-MODE" 'face '(:foreground "#CE2825" :weight bold)) god-mode)))) + (god-local-mode ,(propertize " THANK-GOD-MODE" 'face 'god-mode-lighter) god-mode) + (rainbow-delimiters-mode ,(propertize " Rdelimiters" 'face 'rainbow-delimiters-depth-1-face) rainbow-delimiters)))) ;; 安装gcmh用于管理内存回收 (use-package gcmh @@ -60,8 +61,10 @@ ;; 安装benchmark-init (use-package benchmark-init - :init (benchmark-init/activate) - :hook (after-init . benchmark-init/deactivate)) + :init + (benchmark-init/activate) + :hook + (after-init . benchmark-init/deactivate)) (provide 'init-elpa) diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index 146e6ed..4234e08 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -38,13 +38,6 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (message "enable global-jinx-mode") (global-jinx-mode 1))))))) -(defun duplicate-and-move-to-next-line() - "Duplicate current line and move to next line." - (interactive) - (progn - (duplicate-line) - (next-line))) - (defun popper-toggle-type-delete-other-window() "Toggle type of popper window and delete other window." (interactive) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index e678a76..a63e5e9 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -7,15 +7,21 @@ ;; 修改mac键位 (when *is-mac* (setq mac-command-modifier 'meta) - (setq mac-option-modifier 'none)) + (setq mac-option-modifier 'super) + (setq mac-pass-control-to-system nil) + (setq mac-pass-command-to-system nil)) ;; god-mode (general-def god-local-mode-map "i" 'god-mode-all - "" 'god-mode-all "[" 'backward-paragraph "]" 'forward-paragraph - "." 'repeat) + "." 'repeat + "y" 'yank + "C-c C-" 'scratch-buffer + "z" 'avy-goto-char + "'" 'avy-goto-word-1 + "" 'open-init-file) ;; g for gptel (general-def @@ -34,12 +40,12 @@ :prefix "C-c u" "l" 'global-tab-line-mode "d" 'disable-theme - "r" 'rainbow-mode + "R" 'rainbow-mode "b" 'indent-bars-mode "t" 'consult-theme "c" 'my-color-picker "f" 'describe-face - "R" 'rainbow-delimiters-mode) + "r" 'rainbow-delimiters-mode) ;; f for find and consult command (general-def @@ -232,7 +238,6 @@ (general-def ;; god-mode - "" 'god-mode-all "M-i" 'god-mode-all ;; buffer, file, and window @@ -253,16 +258,16 @@ "M-c" 'capitalize-dwim "M-u" 'upcase-dwim "M-l" 'downcase-dwim - "C-," 'duplicate-and-move-to-next-line + "C-," 'crux-duplicate-current-line-or-region "C-k" 'crux-smart-kill-line "C-" 'crux-kill-line-backwards - "C-o" 'open-line "C-a" 'crux-move-beginning-of-line "M-y" 'consult-yank-from-kill-ring "C-c " 'hungry-delete-backward "C-c C-" 'hungry-delete-forward "M-P" 'drag-stuff-up "M-N" 'drag-stuff-down + "C-M-SPC" 'er/mark-symbol ;; undo "C-/" 'undo-fu-only-undo diff --git a/lisp/init-org.el b/lisp/init-org.el index a9b52ed..3674576 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -64,7 +64,7 @@ ;; org-babel scheme (use-package ob-scheme - :straight (:type built-in) + :straight nil :config (add-to-list 'org-babel-load-languages '(scheme . t)) (org-babel-do-load-languages @@ -137,12 +137,22 @@ ;; 自定义agenda视图 (setq org-agenda-custom-commands - '(("pa" "Priority >= A" - ((tags-todo "+PRIORITY=\"A\""))) - ("pb" "Priority >= B" - ((tags-todo "+PRIORITY<=\"B\""))) - ("pc" "Priority >= C" - ((tags-todo "+PRIORITY<=\"C\""))) + '(("pa" "priority >= A" + ((org-ql-block '(and (priority "A") (todo)) + ((org-ql-block-header "priority = A"))))) + ("pb" "priority >= B" + ((org-ql-block '(and (priority >= "B") (todo)) + ((org-ql-block-header "priority >= B") + (org-super-agenda-groups + '((:name "priority = A" :priority "A") + (:name "priority = B" :priority "B"))))))) + ("pc" "priority >= C" + ((org-ql-block '(and (priority >= "C") (todo)) + ((org-ql-block-header "priority >= C") + (org-super-agenda-groups + '((:name "priority = A" :priority "A") + (:name "priority = B" :priority "B") + (:name "priority = C" :priority "C"))))))) ("qd" "TODO entries sort by closed time" ((org-ql-block '(closed) ((org-ql-block-header "Closed TODOs") @@ -171,8 +181,7 @@ (:name "priority = A" :priority "A") (:name "priority = B" :priority "B") (:name "other priority" :priority< "B") - (:name "someday" :todo "SOMEDAY") - )))))))) + (:name "someday" :todo "SOMEDAY"))))))))) ;; capture模板 (unless *is-windows* diff --git a/lisp/init-package.el b/lisp/init-package.el index 7878f13..1189072 100644 --- a/lisp/init-package.el +++ b/lisp/init-package.el @@ -189,12 +189,15 @@ targets." :delight :init (projectile-mode) + (projectile-known-projects) :bind (:map projectile-mode-map ("C-x p" . projectile-command-map) ("C-x p b" . consult-project-buffer)) :config - (setq projectile-enable-caching t)) + (setq projectile-enable-caching 'persistent) + (setq projectile-auto-discover t) + (setq projectile-auto-cleanup-known-projects t)) ;; ibuffer (use-package ibuffer @@ -238,7 +241,9 @@ targets." (mode . magit-log-mode) (mode . magit-process-mode) (mode . magit-status-mode))) - ("Directories" (mode . dired-mode)) + ("Directories" (or + (mode . dired-mode) + (name . "^*dirvish"))) ("Diff" (name . "^*Diff"))))) (add-hook 'ibuffer-hook @@ -247,7 +252,8 @@ targets." (ibuffer-do-sort-by-alphabetic)))) (setq ibuffer-show-empty-filter-groups nil) - (setq ibuffer-use-other-window t)) + (setq ibuffer-use-other-window t) + (setq ibuffer-default-sorting-mode 'filename)) ;; avy中文支持 (use-package ace-pinyin @@ -285,10 +291,6 @@ targets." (modify-syntax-entry (+ start i) "_" jinx--syntax-table))))) (require 'init-jinx))) -;; vterm,终端 -;; (unless *is-windows* -;; (use-package vterm)) - ;; eat,终端 (use-package eat :straight diff --git a/lisp/init-prog.el b/lisp/init-prog.el index dc094f5..8af22f1 100644 --- a/lisp/init-prog.el +++ b/lisp/init-prog.el @@ -25,13 +25,6 @@ (global-treesit-auto-mode) (setq treesit-font-lock-level 4)) -;; lua -(use-package lua-ts-mode - :mode - ("\\.lua\\'" . lua-ts-mode) - :config - (add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode))) - ;; scheme (use-package geiser :config diff --git a/lisp/init-startup.el b/lisp/init-startup.el index 4f69f7d..628dbb1 100644 --- a/lisp/init-startup.el +++ b/lisp/init-startup.el @@ -7,6 +7,7 @@ ;; mac自动全屏 (cond (*is-mac* + (set-frame-parameter nil 'fullscreen 'fullscreen) (toggle-frame-fullscreen) (global-unset-key (kbd "")) (global-set-key (kbd "") 'toggle-frame-fullscreen)) @@ -83,9 +84,6 @@ (with-eval-after-load 'elec-pair (add-to-list 'electric-pair-pairs '(?\~ . ?\~))) -;; ibuffer -(setq ibuffer-default-sorting-mode 'filename) - ;; 关闭native compile警告 (setq native-comp-async-warnings-errors-kind 'silent) @@ -107,6 +105,9 @@ (setq switch-to-buffer-obey-display-actions t) +;; 优化中文混排时的换行规则 +(setq word-wrap-by-category t) + (provide 'init-startup) ;;; init-startup.el ends here diff --git a/lisp/init-terminal-kbd.el b/lisp/init-terminal-kbd.el index 4aa1318..87832f4 100644 --- a/lisp/init-terminal-kbd.el +++ b/lisp/init-terminal-kbd.el @@ -21,6 +21,19 @@ (general-def "C-c " 'scratch-buffer) (general-def "C-c " 'scratch-buffer)) +;; god-mode +(general-def god-local-mode-map + "i" 'god-mode-all + "" 'god-mode-all + "[" 'backward-paragraph + "]" 'forward-paragraph + "." 'repeat + "y" 'yank + "C-c C-" 'scratch-buffer + "z" 'avy-goto-char + "'" 'avy-goto-word-1 + "" 'open-init-file) + ;; global map with C-c prefix (general-def :prefix "C-c" @@ -32,6 +45,10 @@ ;; global map (general-def + ;; god-mode + "" 'god-mode-all + "M-i" 'god-mode-all + ;; buffer, file, and window "" 'open-init-file "M-[" 'previous-buffer @@ -47,7 +64,6 @@ "C-," 'duplicate-and-move-to-next-line "C-k" 'crux-smart-kill-line "C-" 'crux-kill-line-backwards - "C-o" 'open-line "C-a" 'crux-move-beginning-of-line "M-y" 'yank-from-kill-ring "C-c DEL" 'hungry-delete-backward @@ -76,7 +92,6 @@ (lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer))) "show diff between the buffer and its file")) - (provide 'init-terminal-kbd) ;;; init-terminal-kbd.el ends here diff --git a/lisp/init-terminal-package.el b/lisp/init-terminal-package.el index 9e1170c..feb0908 100644 --- a/lisp/init-terminal-package.el +++ b/lisp/init-terminal-package.el @@ -57,6 +57,24 @@ ;; general (use-package general) +;; god-mode,模态编辑 +(use-package god-mode + :config + (setq god-mode-enable-function-key-translation nil) + (custom-set-faces + '(god-mode-lighter ((t (:inherit straight-process-error))))) + + (defun my-sync-line-numbers-with-god-mode () + (let ((desired (if (bound-and-true-p god-local-mode) + 'relative + t))) + (unless (or (eq display-line-numbers desired) (bound-and-true-p olivetti-mode)) + (setq display-line-numbers desired)))) + (add-hook 'post-command-hook #'my-sync-line-numbers-with-god-mode) + + (setq god-exempt-major-modes + (delete-dups (append '(diff-mode exwm-mode) god-exempt-major-modes)))) + (provide 'init-terminal-package) ;;; init-terminal-package.el ends here diff --git a/lisp/init-terminal-startup.el b/lisp/init-terminal-startup.el index 095e03d..ef0f25d 100644 --- a/lisp/init-terminal-startup.el +++ b/lisp/init-terminal-startup.el @@ -51,21 +51,28 @@ (when (display-graphic-p) (recentf-mode) - (setq recentf-max-saved-items 30)) ;; 最大保存数量 + (setq recentf-max-saved-items 30)) (delete-selection-mode) (setq initial-scratch-message "") -(setq ibuffer-default-sorting-mode 'filename) - (setq native-comp-async-warnings-errors-kind 'silent) (if (boundp 'use-short-answers) (setq use-short-answers t) (fset 'yes-or-no-p 'y-or-n-p)) +(setq delete-by-moving-to-trash t) + +(setq xref-search-program + (cond + ((or (executable-find "ripgrep") + (executable-find "rg")) + 'ripgrep) + (t 'grep))) + (provide 'init-terminal-startup) ;;; init-terminal-statup.el ends here diff --git a/lisp/init-ui.el b/lisp/init-ui.el index 7fb0b9c..c75b110 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -54,7 +54,9 @@ (setq custom-safe-themes t) ;; 安装solarized dark -(use-package solarized-theme) +(use-package solarized-theme + :straight + '(solarized-emacs :fork (:host github :repo "Andsy10/solarized-emacs"))) ;; 把主题加载延迟到frame创建之后,防止daemon模式下宏不能正常展开 (if (daemonp) @@ -119,8 +121,8 @@ ;; 安装cnfonts脚本,用于修复中英文对齐 (use-package cnfonts - :hook - (after-init-hook . cnfonts-mode) + :init + (add-hook 'after-init-hook 'cnfonts-mode) :config (cnfonts--select-profile "profile1")) diff --git a/lisp/init-window.el b/lisp/init-window.el index cbf42e6..152810f 100644 --- a/lisp/init-window.el +++ b/lisp/init-window.el @@ -74,7 +74,7 @@ "^\\*elfeed-entry\\*$" "^\\*macro expansion\\**" - "\\*Agenda Commands\\*" "\\*Org Select\\*" "\\*Capture\\*" "^CAPTURE-.*\\.org*" + "\\*Agenda Commands\\*" "\\*Org Select\\*" "\\*Capture\\*" "^CAPTURE-.*\\.org*" "^CAPTURE-" "\\*Gofmt Errors\\*$" "\\*Go Test\\*$" godoc-mode "\\*docker-containers\\*" "\\*docker-images\\*" "\\*docker-networks\\*" "\\*docker-volumes\\*" "\\*prolog\\*" inferior-python-mode inf-ruby-mode swift-repl-mode diff --git a/lisp/my-base16-dark-theme.el b/lisp/my-base16-dark-theme.el index 579273a..7072fb3 100644 --- a/lisp/my-base16-dark-theme.el +++ b/lisp/my-base16-dark-theme.el @@ -52,11 +52,17 @@ `(mode-line ((,class (:foreground ,base0 :background ,base02)))) `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03)))) `(display-time-date-and-time ((,class (:foreground ,base1 :bold t)))) - `(jinx-misspelled ((,class (:underline (:style dashes :color ,yellow))))) + `(jinx-misspelled ((,class (:underline (:style line :color ,yellow))))) `(geiser-font-lock-repl-output ((,class (:foreground ,green)))) `(geiser-font-lock-doc-link ((,class (:foreground ,blue :underline t)))) `(geiser-font-lock-error-link ((,class (:foreground ,orange :underline t)))) - `(vertico-current ((,class (:background ,base02 :extend t :underline nil))))))) + `(vertico-current ((,class (:background ,base02 :extend t :underline nil)))) + `(vundo-saved ((,class (:foreground ,green)))) + `(vundo-last-saved ((,class (:foreground ,green :weight bold)))) + `(vundo-highlight ((,class (:foreground ,cyan :weight bold)))) + `(vundo-node ((,class (:foreground ,base01)))) + `(vundo-stem ((,class (:foreground ,base01)))) + `(god-mode-lighter ((,class (:foreground ,red :weight bold))))))) (provide-theme 'my-base16-dark) diff --git a/lisp/my-base16-light-theme.el b/lisp/my-base16-light-theme.el index 2c44040..70a4c4e 100644 --- a/lisp/my-base16-light-theme.el +++ b/lisp/my-base16-light-theme.el @@ -52,11 +52,17 @@ `(mode-line ((,class (:foreground ,base0 :background ,base02)))) `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03)))) `(display-time-date-and-time ((,class (:foreground ,base1 :bold t)))) - `(jinx-misspelled ((,class (:underline (:style dashes :color ,yellow))))) + `(jinx-misspelled ((,class (:underline (:style line :color ,yellow))))) `(geiser-font-lock-repl-output ((,class (:foreground ,green)))) `(geiser-font-lock-doc-link ((,class (:foreground ,blue :underline t)))) `(geiser-font-lock-error-link ((,class (:foreground ,orange :underline t)))) - `(vertico-current ((,class (:background ,base02 :extend t :underline nil))))))) + `(vertico-current ((,class (:background ,base02 :extend t :underline nil)))) + `(vundo-saved ((,class (:foreground ,green)))) + `(vundo-last-saved ((,class (:foreground ,green :weight bold)))) + `(vundo-highlight ((,class (:foreground ,cyan :weight bold)))) + `(vundo-node ((,class (:foreground ,base01)))) + `(vundo-stem ((,class (:foreground ,base01)))) + `(god-mode-lighter ((,class (:foreground ,red :weight bold))))))) (provide-theme 'my-base16-light)