From 6fa40215ca790c7ce897b31bed4db17cefa6b78f Mon Sep 17 00:00:00 2001 From: dej4vu Date: Mon, 8 Jul 2024 15:56:11 +0800 Subject: [PATCH 1/6] minor optimize --- lisp/init-editing-utils.el | 5 +++++ lisp/init-themes.el | 1 + lisp/init-ui.el | 1 + 3 files changed, 7 insertions(+) diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index bc71bf4..c285c18 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -19,6 +19,7 @@ ;; clang-format (use-package clang-format :ensure t + :defer t ) (add-hook 'prog-mode-hook 'hs-minor-mode) @@ -28,6 +29,7 @@ :ensure t :init (golden-ratio-mode +1) + :defer t :config (setq golden-ratio-extra-commands (append golden-ratio-extra-commands @@ -78,6 +80,9 @@ ;; global toggle commentary (global-set-key (kbd "C-c C-c") 'comment-line) +;; insert newline below and jumpt to it +(global-set-key (kbd "") (kbd "C-e C-m")) + ;; multiple-cursors (use-package multiple-cursors :ensure t diff --git a/lisp/init-themes.el b/lisp/init-themes.el index f51e6f1..5c49bd2 100644 --- a/lisp/init-themes.el +++ b/lisp/init-themes.el @@ -7,5 +7,6 @@ (load-theme 'ample-light t t) ;; choose one to enable (enable-theme 'ample) + :defer t ) (provide 'init-themes) diff --git a/lisp/init-ui.el b/lisp/init-ui.el index 8a81a87..d72a03a 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -2,6 +2,7 @@ ;; show keybindings (use-package which-key :ensure t + :defer t :init (setq which-key-idle-delay 2.0) ;;:config From 0db42b5a10d26f21d8a14c59ceabbc5cde869604 Mon Sep 17 00:00:00 2001 From: dej4vu Date: Fri, 19 Jul 2024 13:07:54 +0800 Subject: [PATCH 2/6] load theme by day --- lisp/init-themes.el | 47 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/lisp/init-themes.el b/lisp/init-themes.el index 5c49bd2..5ae07ef 100644 --- a/lisp/init-themes.el +++ b/lisp/init-themes.el @@ -2,11 +2,50 @@ (use-package ample-theme :ensure t :init - (load-theme 'ample t t) - (load-theme 'ample-flat t t) - (load-theme 'ample-light t t) + (load-theme 'ample t nil) + (load-theme 'ample-flat t nil) + (load-theme 'ample-light t nil) ;; choose one to enable - (enable-theme 'ample) + ;;(enable-theme 'ample) :defer t ) + +(use-package solarized-theme + :ensure t + :defer t + ) + +(use-package plan9-theme + :ensure t + :defer t + ) + +(use-package doom-themes + :ensure t + :defer t + ) + +(use-package doom-themes + :ensure t + :defer t + ) + +(use-package dracula-theme + :ensure t + :defer t + ) + +(defun dej4vu/today-emacs-theme () + "Chooses a theme based on the day." + (interactive) + (let* ((themes-list (list 'ample 'solarized-light 'plan9 'doom-dark+ 'dracula)) + (themes-len (length themes-list)) + (today-as-number (string-to-number (format-time-string "%Y%m%d%j"))) + (theme-index (% today-as-number themes-len)) + (theme-index 4) + (theme-sym (nth theme-index themes-list))) + (message "Loading theme: %s" theme-sym) + (load-theme theme-sym t))) +(dej4vu/today-emacs-theme) + (provide 'init-themes) From 383d8a33253ca616b69ee8fc835d8d73952776ae Mon Sep 17 00:00:00 2001 From: dej4vu Date: Fri, 19 Jul 2024 13:08:43 +0800 Subject: [PATCH 3/6] add llm --- init.el | 3 ++- lisp/init-llm.el | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lisp/init-llm.el diff --git a/init.el b/init.el index 3847564..2df084c 100644 --- a/init.el +++ b/init.el @@ -6,7 +6,7 @@ (package-initialize) ;;(setq debug-on-error t) -(let ((minver "24.3")) +(let ((minver "29.3")) (when (version< emacs-version minver) (error "This config requires Emacs v%s or higher" minver))) (setq emacs-load-start-time (current-time)) @@ -52,6 +52,7 @@ (require 'init-vc) (require 'init-exec-path) (require 'init-yas) +(require 'init-llm) (when (file-exists-p custom-file) (load custom-file)) diff --git a/lisp/init-llm.el b/lisp/init-llm.el new file mode 100644 index 0000000..cf18e7f --- /dev/null +++ b/lisp/init-llm.el @@ -0,0 +1,17 @@ +(use-package gptel + :ensure t + :defer t + :init + (setq + gptel-model "qwen2:7b" + gptel-backend (gptel-make-ollama "Ollama" + :host "localhost:11434" + :stream t + :models '("qwen2:7b"))) + :config + (setq gptel-api-key "your key") + (add-hook 'gptel-post-response-functions 'gptel-end-of-response) + (add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) + ) + +(provide 'init-llm) From 6a5edb92a55bba3bc6f10ca1f77e579960a3e7fa Mon Sep 17 00:00:00 2001 From: dej4vu Date: Wed, 24 Jul 2024 16:42:43 +0800 Subject: [PATCH 4/6] use doom-mode --- lisp/init-ui.el | 197 +++++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 84 deletions(-) diff --git a/lisp/init-ui.el b/lisp/init-ui.el index d72a03a..9fbdded 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -12,7 +12,21 @@ (if window-system (menu-bar-mode +1) ;; disable menu bar - (menu-bar-mode -1)) + (menu-bar-mode -1) + ) + +(defun prettify-continuation-indocator (&optional dummy) + (ignore dummy) + (when buffer-display-table + (set-display-table-slot buffer-display-table 'wrap ?↩))) + +(unless window-system + (set-display-table-slot standard-display-table 'wrap ?↩) + (add-hook 'window-configuration-change-hook 'prettify-continuation-indocator) + ;; 如果还有问题,试着启用以下设置 + ;; (with-eval-after-load 'page-break-lines + ;; (add-hook 'page-break-lines-mode-hook 'prettify-continuation-indocator)) + ) (when (display-graphic-p) ;; disable scroll bar @@ -182,89 +196,104 @@ (`interrupted " -") (`suspicious '(propertize " ?" 'face 'warning)))))) -(setq-default mode-line-format - (list - anzu--mode-line-format - ;; " %1" - ;; '(:eval (propertize - ;; (window-number-mode-line) - ;; 'face - ;; 'font-lock-type-face)) - ;; " " - ;; '(:eval (zilongshanren/update-persp-name)) - - "%1 " - ;; the buffer name; the file name as a tool tip - '(:eval (propertize "%b " 'face 'font-lock-function-name-face - 'help-echo (buffer-file-name))) - - - " [" ;; insert vs overwrite mode, input-method in a tooltip - '(:eval (propertize (if overwrite-mode "Ovr" "Ins") - 'face 'font-lock-preprocessor-face - 'help-echo (concat "Buffer is in " - (if overwrite-mode - "overwrite" - "insert") " mode"))) - - ;; was this buffer modified since the last save? - '(:eval (when (buffer-modified-p) - (concat "," (propertize "Mod" - 'face 'font-lock-function-name-face - 'help-echo "Buffer has been modified")))) - - ;; is this buffer read-only? - '(:eval (when buffer-read-only - (concat "," (propertize "RO" - 'face 'font-lock-type-face - 'help-echo "Buffer is read-only")))) - "] " - - - ;; relative position, size of file - "[" - (propertize "%p" 'face 'font-lock-function-name-face) ;; % above top - "/" - (propertize "%I" 'face 'font-lock-function-name-face) ;; size - "] " - - ;; the current major mode for the buffer. - '(:eval (propertize "%m" 'face 'font-lock-string-face - 'help-echo buffer-file-coding-system)) - - "%1 " - my-flycheck-mode-line - "%1 " - ;; evil state - '(:eval evil-mode-line-tag) - - ;; minor modes - ;;minor-mode-alist - minions-mode-line-modes - " " - ;; git info - `(vc-mode vc-mode) - - " " - - ;; global-mode-string goes in mode-line-misc-info - mode-line-misc-info - - (mode-line-fill 'mode-line 20) - - ;; line and column - "(" ;; '%02' to set to 2 chars at least; prevents flickering - (propertize "%02l" 'face 'font-lock-function-name-face) "," - (propertize "%02c" 'face 'font-lock-function-name-face) - ") " +;;(setq-default mode-line-format +;; (list +;; anzu--mode-line-format +;; ;; " %1" +;; ;; '(:eval (propertize +;; ;; (window-number-mode-line) +;; ;; 'face +;; ;; 'font-lock-type-face)) +;; ;; " " +;; ;; '(:eval (zilongshanren/update-persp-name)) +;; +;; "%1 " +;; ;; the buffer name; the file name as a tool tip +;; '(:eval (propertize "%b " 'face 'font-lock-function-name-face +;; 'help-echo (buffer-file-name))) +;; +;; +;; " [" ;; insert vs overwrite mode, input-method in a tooltip +;; '(:eval (propertize (if overwrite-mode "Ovr" "Ins") +;; 'face 'font-lock-preprocessor-face +;; 'help-echo (concat "Buffer is in " +;; (if overwrite-mode +;; "overwrite" +;; "insert") " mode"))) +;; +;; ;; was this buffer modified since the last save? +;; '(:eval (when (buffer-modified-p) +;; (concat "," (propertize "Mod" +;; 'face 'font-lock-function-name-face +;; 'help-echo "Buffer has been modified")))) +;; +;; ;; is this buffer read-only? +;; '(:eval (when buffer-read-only +;; (concat "," (propertize "RO" +;; 'face 'font-lock-type-face +;; 'help-echo "Buffer is read-only")))) +;; "] " +;; +;; +;; ;; relative position, size of file +;; "[" +;; (propertize "%p" 'face 'font-lock-function-name-face) ;; % above top +;; "/" +;; (propertize "%I" 'face 'font-lock-function-name-face) ;; size +;; "] " +;; +;; ;; the current major mode for the buffer. +;; '(:eval (propertize "%m" 'face 'font-lock-string-face +;; 'help-echo buffer-file-coding-system)) +;; +;; "%1 " +;; my-flycheck-mode-line +;; "%1 " +;; ;; evil state +;; '(:eval evil-mode-line-tag) +;; +;; ;; minor modes +;; ;;minor-mode-alist +;; minions-mode-line-modes +;; " " +;; ;; git info +;; `(vc-mode vc-mode) +;; +;; " " +;; +;; ;; global-mode-string goes in mode-line-misc-info +;; mode-line-misc-info +;; +;; (mode-line-fill 'mode-line 20) +;; +;; ;; line and column +;; "(" ;; '%02' to set to 2 chars at least; prevents flickering +;; (propertize "%02l" 'face 'font-lock-function-name-face) "," +;; (propertize "%02c" 'face 'font-lock-function-name-face) +;; ") " +;; +;; '(:eval (buffer-encoding-abbrev)) +;; mode-line-end-spaces +;; ;; add the time, with the date and the emacs uptime in the tooltip +;; ;; '(:eval (propertize (format-time-string "%H:%M") +;; ;; 'help-echo +;; ;; (concat (format-time-string "%c; ") +;; ;; (emacs-uptime "Uptime:%hh")))) +;; )) + +(use-package nerd-icons + ;; :custom + ;; The Nerd Font you want to use in GUI + ;; "Symbols Nerd Font Mono" is the default and is recommended + ;; but you can use any other Nerd Font if you want + ;; (nerd-icons-font-family "Symbols Nerd Font Mono") + ) - '(:eval (buffer-encoding-abbrev)) - mode-line-end-spaces - ;; add the time, with the date and the emacs uptime in the tooltip - ;; '(:eval (propertize (format-time-string "%H:%M") - ;; 'help-echo - ;; (concat (format-time-string "%c; ") - ;; (emacs-uptime "Uptime:%hh")))) - )) +(use-package doom-modeline + :ensure t + :init + (setq nerd-icons-color-icons nil) + (doom-modeline-mode 1) + ) (provide 'init-ui) From 7dc3142b16a42544015b8a41a3ff3b07de86a7d3 Mon Sep 17 00:00:00 2001 From: dej4vu Date: Wed, 24 Jul 2024 16:43:08 +0800 Subject: [PATCH 5/6] use orderless --- lisp/init-helm.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/init-helm.el b/lisp/init-helm.el index 0346ee5..5f5c74d 100644 --- a/lisp/init-helm.el +++ b/lisp/init-helm.el @@ -14,7 +14,8 @@ ("C-x C-f" . helm-find-files) ("C-x C-r" . helm-recentf) ("C-x b" . helm-mini) - ("M-x" . helm-M-x)) + ;;("M-x" . helm-M-x) + ) ) ;; helm-smex @@ -59,6 +60,14 @@ ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; (setq vertico-cycle t) ) + +;; 补全 +(use-package orderless + :ensure t + :custom + (completion-styles '(orderless flex)) + (completion-category-overrides '((file (styles basic partial-completion))))) + ;; Persist history over Emacs restarts. Vertico sorts by history position. (use-package savehist :init From 7af9efeb1f29627e2839e3bcb52310c1e82f1992 Mon Sep 17 00:00:00 2001 From: dej4vu Date: Wed, 24 Jul 2024 16:43:39 +0800 Subject: [PATCH 6/6] optmize lsp --- lisp/init-lsp.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/init-lsp.el b/lisp/init-lsp.el index af0f368..e92e796 100644 --- a/lisp/init-lsp.el +++ b/lisp/init-lsp.el @@ -18,6 +18,9 @@ ;; )) ;;:custom ;;(setq lsp-enable-snippet t) + ;;排除'/opt/homebrew'目录下所有文件 + (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]opt/homebrew") + :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode) (go-mode . lsp-defered) (python-mode . lsp-deferred)