feat: add dashboard and enhance completion
- Add startup dashboard with recent files and bookmarks - Enhance corfu with icons and minibuffer transfer - Add avy-zap, markdown-mode, consult-dir - Optimize GC settings and editor config
This commit is contained in:
1
init.el
1
init.el
@@ -22,6 +22,7 @@
|
||||
(require 'init-window)
|
||||
(require 'init-kbd)
|
||||
(require 'init-ui)
|
||||
(require 'init-dashboard)
|
||||
(require 'init-segmentation)
|
||||
|
||||
;;; init.el ends here
|
||||
|
||||
@@ -13,30 +13,59 @@
|
||||
|
||||
;; corfu
|
||||
(use-package corfu
|
||||
:init
|
||||
(global-corfu-mode)
|
||||
(corfu-history-mode)
|
||||
(corfu-popupinfo-mode)
|
||||
(corfu-echo-mode)
|
||||
|
||||
:autoload (corfu-quit consult-completion-in-region)
|
||||
:functions (persistent-scratch-save corfu-move-to-minibuffer)
|
||||
:custom
|
||||
(corfu-auto t)
|
||||
(corfu-cycle t)
|
||||
(corfu-auto-delay 0.1)
|
||||
(corfu-popupinfo-delay 0.2)
|
||||
(corfu-preview-current nil)
|
||||
(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))
|
||||
:hook ((after-init . global-corfu-mode)
|
||||
(global-corfu-mode . corfu-popupinfo-mode)
|
||||
(global-corfu-mode . corfu-history-mode))
|
||||
|
||||
:bind
|
||||
(:map corfu-map
|
||||
:config
|
||||
;;Quit completion before saving
|
||||
(add-hook 'before-save-hook #'corfu-quit)
|
||||
(advice-add #'persistent-scratch-save :before #'corfu-quit)
|
||||
|
||||
;; Move completions to minibuffer
|
||||
(defun corfu-move-to-minibuffer ()
|
||||
(interactive)
|
||||
(pcase completion-in-region--data
|
||||
(`(,beg ,end ,table ,pred ,extras)
|
||||
(let ((completion-extra-properties extras)
|
||||
completion-cycle-threshold completion-cycling)
|
||||
(consult-completion-in-region beg end table pred)))))
|
||||
(keymap-set corfu-map "M-m" #'corfu-move-to-minibuffer)
|
||||
(add-to-list 'corfu-continue-commands #'corfu-move-to-minibuffer)
|
||||
|
||||
:bind (:map corfu-map
|
||||
("RET" . nil)))
|
||||
|
||||
(unless (or (display-graphic-p)
|
||||
(featurep 'tty-child-frames))
|
||||
(use-package corfu-terminal
|
||||
:hook (global-corfu-mode . corfu-terminal-mode)))
|
||||
|
||||
;; 在eshell中使用tab打开补全
|
||||
(add-hook 'eshell-mode-hook
|
||||
(lambda ()
|
||||
(setq-local corfu-auto nil)
|
||||
(local-set-key (kbd "TAB") 'completion-at-point)))
|
||||
|
||||
(use-package nerd-icons-completion
|
||||
:hook (marginalia-mode . nerd-icons-completion-marginalia-setup))
|
||||
|
||||
(use-package emacs
|
||||
:custom
|
||||
(tab-always-indent 'complete)
|
||||
@@ -52,10 +81,23 @@
|
||||
|
||||
;; cape
|
||||
(use-package cape
|
||||
:commands (cape-file cape-elisp-block cape-keyword)
|
||||
:autoload (cape-wrap-noninterruptible cape-wrap-nonexclusive cape-wrap-buster)
|
||||
:autoload (cape-wrap-silent)
|
||||
:init
|
||||
(add-to-list 'completion-at-point-functions #'cape-file) ;; 文件补全
|
||||
(setq-local completion-at-point-functions
|
||||
(list (cape-capf-super #'cape-dabbrev)))) ;; 启用dabbrev
|
||||
;; (add-to-list 'completion-at-point-functions #'cape-dabbrev)
|
||||
(add-to-list 'completion-at-point-functions #'cape-file)
|
||||
(add-to-list 'completion-at-point-functions #'cape-elisp-block)
|
||||
(add-to-list 'completion-at-point-functions #'cape-keyword)
|
||||
;; (add-to-list 'completion-at-point-functions #'cape-abbrev)
|
||||
|
||||
;; Make these capfs composable.
|
||||
(advice-add 'lsp-completion-at-point :around #'cape-wrap-noninterruptible)
|
||||
(advice-add 'lsp-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add 'comint-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
|
||||
(advice-add 'eglot-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive))
|
||||
|
||||
;; lua
|
||||
(use-package lua-ts-mode
|
||||
|
||||
34
lisp/init-dashboard.el
Normal file
34
lisp/init-dashboard.el
Normal file
@@ -0,0 +1,34 @@
|
||||
;;; init-dashboard.el --- dashboard -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(use-package dashboard
|
||||
:demand t
|
||||
:config
|
||||
(dashboard-setup-startup-hook)
|
||||
(setq dashboard-banner-logo-title (format "%s" emacs-version))
|
||||
(setq dashboard-banner-ascii " ##### # # # # ####### # # # ##### ##### \n# # ## # # # # ## ## # # # # # # \n# # # # # # # # # # # # # # # \n# #### # # # # # ##### # # # # # # ##### \n# # # # # # # # # # ####### # # \n# # # ## # # # # # # # # # # # \n ##### # # ##### ####### # # # # ##### ##### ")
|
||||
(setq dashboard-startup-banner 'ascii)
|
||||
(setq dashboard-center-content t)
|
||||
(setq dashboard-navigation-cycle t)
|
||||
(setq dashboard-items '((recents . 10)
|
||||
(bookmarks . 5)
|
||||
(projects . 5)))
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda()
|
||||
(setq my-emacs-startup-time (format-time-string "%Y-%m-%d %H:%M:%S"))))
|
||||
(defun my/dashboard-insert-copyright ()
|
||||
"Insert copyright in the footer."
|
||||
(dashboard-insert-center
|
||||
(propertize (format "\n\nEmacs started at %s" my-emacs-startup-time)
|
||||
'face 'font-lock-comment-face)))
|
||||
(advice-add #'dashboard-insert-footer :after #'my/dashboard-insert-copyright)
|
||||
(setq dashboard-footer-messages '(
|
||||
"Hello."
|
||||
"Hi."
|
||||
)))
|
||||
|
||||
(provide 'init-dashboard)
|
||||
;;; init-dashboard.el ends here
|
||||
@@ -286,6 +286,10 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
(list "d"
|
||||
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
|
||||
"show diff between the buffer and its file"))
|
||||
;; markdown
|
||||
(with-eval-after-load 'markdown-mode
|
||||
(define-key markdown-mode-map (kbd "M-p") nil)
|
||||
(define-key markdown-mode-map (kbd "M-n") nil))
|
||||
|
||||
;; org-mode相关
|
||||
;; cycle当前subtree
|
||||
@@ -359,6 +363,9 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
||||
|
||||
(global-set-key (kbd "C-c m d") 'my-emms-play-directory)
|
||||
|
||||
;; dashboard
|
||||
(global-set-key (kbd "C-c <ESC>") 'dashboard-open)
|
||||
|
||||
(provide 'init-kbd)
|
||||
|
||||
;;; init-kbd.el ends here
|
||||
|
||||
@@ -156,7 +156,6 @@
|
||||
(when *is-windows*
|
||||
(with-eval-after-load 'org
|
||||
(setq org-agenda-files '("d:/emacs/hugo/this-is-my-blog/all-blog.org"
|
||||
"d:/emacs/my-org-daily/"
|
||||
"d:/emacs/my-org-daily/"))))
|
||||
(when *is-mac*
|
||||
(with-eval-after-load 'org
|
||||
|
||||
@@ -8,12 +8,53 @@
|
||||
|
||||
;; 安装gcmh用于管理内存回收
|
||||
(use-package gcmh
|
||||
:demand t
|
||||
:init
|
||||
(setq gcmh-idle-delay 5 ; 空闲 5 秒后 GC
|
||||
gcmh-high-cons-threshold (* 16 1024 1024)) ; 高阈值 16MB
|
||||
(setq gcmh-idle-delay 'auto
|
||||
gcmh-auto-idle-delay-factor 10
|
||||
gcmh-high-cons-threshold #x4000000)
|
||||
:config
|
||||
(gcmh-mode 1))
|
||||
|
||||
(use-package emacs
|
||||
:hook (((prog-mode markdown-mode conf-mode) . enable-trailing-whitespace))
|
||||
:init
|
||||
(setq kill-whole-line t ; Kill line including '\n'
|
||||
line-move-visual nil
|
||||
track-eol t ; Keep cursor at end of lines. Require line-move-visual is nil.
|
||||
set-mark-command-repeat-pop t) ; Repeating C-SPC after popping mark pops it again
|
||||
|
||||
;; Visualize TAB, (HARD) SPACE, NEWLINE
|
||||
(setq-default show-trailing-whitespace nil) ; Don't show trailing whitespace by default
|
||||
(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))
|
||||
|
||||
;; Prettify the process list
|
||||
(with-no-warnings
|
||||
(defun my/list-processes--prettify ()
|
||||
"Prettify process list."
|
||||
(when-let* ((entries tabulated-list-entries))
|
||||
(setq tabulated-list-entries nil)
|
||||
(dolist (p (process-list))
|
||||
(when-let* ((val (cadr (assoc p entries)))
|
||||
(name (aref val 0))
|
||||
(pid (aref val 1))
|
||||
(status (aref val 2))
|
||||
(status (list status
|
||||
'face
|
||||
(if (memq status '(stop exit closed failed))
|
||||
'error
|
||||
'success)))
|
||||
(buf-label (aref val 3))
|
||||
(tty (list (aref val 4) 'face 'font-lock-doc-face))
|
||||
(thread (list (aref val 5) 'face 'font-lock-doc-face))
|
||||
(cmd (list (aref val 6) 'face 'completions-annotations)))
|
||||
(push (list p (vector name pid status buf-label tty thread cmd))
|
||||
tabulated-list-entries)))))
|
||||
(advice-add #'list-processes--refresh :after #'my/list-processes--prettify)))
|
||||
|
||||
(use-package restart-emacs)
|
||||
|
||||
;; 安装multiple-cursors
|
||||
@@ -65,9 +106,69 @@
|
||||
(when *is-mac*
|
||||
(setopt consult-locate-args "mdfind -name")))
|
||||
|
||||
;; 安装embark,一个菜单,用用就明白了
|
||||
(use-package consult-dir
|
||||
:bind (("C-x C-d" . consult-dir)
|
||||
:map minibuffer-local-completion-map
|
||||
("C-x C-d" . consult-dir)
|
||||
("C-x C-j" . consult-dir-jump-file)))
|
||||
|
||||
;; embark
|
||||
(use-package embark
|
||||
:config (setq prefix-help-command 'embark-prefix-help-command))
|
||||
:config (setq prefix-help-command 'embark-prefix-help-command)
|
||||
:init
|
||||
(defun my/embark-preview ()
|
||||
"Previews candidate in vertico buffer, unless it's a consult command."
|
||||
(interactive)
|
||||
(unless (bound-and-true-p consult--preview-function)
|
||||
(save-selected-window
|
||||
(let ((embark-quit-after-action nil))
|
||||
(embark-dwim)))))
|
||||
|
||||
;; Hide the mode line of the Embark live/completions buffers
|
||||
(add-to-list 'display-buffer-alist
|
||||
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
|
||||
nil
|
||||
(window-parameters (mode-line-format . none))))
|
||||
|
||||
(with-no-warnings
|
||||
(with-eval-after-load 'which-key
|
||||
(defun embark-which-key-indicator ()
|
||||
"An embark indicator that displays keymaps using which-key.
|
||||
The which-key help message will show the type and value of the
|
||||
current target followed by an ellipsis if there are further
|
||||
targets."
|
||||
(lambda (&optional keymap targets prefix)
|
||||
(if (null keymap)
|
||||
(which-key--hide-popup-ignore-command)
|
||||
(which-key--show-keymap
|
||||
(if (eq (plist-get (car targets) :type) 'embark-become)
|
||||
"Become"
|
||||
(format "Act on %s '%s'%s"
|
||||
(plist-get (car targets) :type)
|
||||
(embark--truncate-target (plist-get (car targets) :target))
|
||||
(if (cdr targets) "…" "")))
|
||||
(if prefix
|
||||
(pcase (lookup-key keymap prefix 'accept-default)
|
||||
((and (pred keymapp) km) km)
|
||||
(_ (key-binding prefix 'accept-default)))
|
||||
keymap)
|
||||
nil nil t (lambda (binding)
|
||||
(not (string-suffix-p "-argument" (cdr binding))))))))
|
||||
|
||||
(setq embark-indicators
|
||||
'(embark-which-key-indicator
|
||||
embark-highlight-indicator
|
||||
embark-isearch-highlight-indicator))
|
||||
|
||||
(defun embark-hide-which-key-indicator (fn &rest args)
|
||||
"Hide the which-key indicator immediately when using the completing-read prompter."
|
||||
(which-key--hide-popup-ignore-command)
|
||||
(let ((embark-indicators
|
||||
(remq #'embark-which-key-indicator embark-indicators)))
|
||||
(apply fn args)))
|
||||
|
||||
(advice-add #'embark-completing-read-prompter
|
||||
:around #'embark-hide-which-key-indicator))))
|
||||
|
||||
;; 安装embark-consult和wgrep
|
||||
(use-package embark-consult)
|
||||
@@ -83,6 +184,9 @@
|
||||
'embark-collect-mode-hook
|
||||
#'consult-preview-at-point-mode))))
|
||||
|
||||
;; nerd-icon
|
||||
(use-package nerd-icons)
|
||||
|
||||
;; 启用savehist,保存命令顺序
|
||||
(use-package savehist
|
||||
:hook (after-init . savehist-mode)
|
||||
@@ -116,16 +220,36 @@
|
||||
|
||||
;; ibuffer-projectile
|
||||
(use-package ibuffer-projectile
|
||||
:init (add-hook 'ibuffer-hook
|
||||
:config (add-hook 'ibuffer-hook
|
||||
(lambda ()
|
||||
(ibuffer-projectile-set-filter-groups)
|
||||
(unless (eq ibuffer-sorting-mode 'alphabetic)
|
||||
(ibuffer-do-sort-by-alphabetic)))))
|
||||
(ibuffer-do-sort-by-alphabetic))))
|
||||
(when (centaur-treesit-available-p)
|
||||
(defun treesit-mark-bigger-node ()
|
||||
"Use tree-sitter to mark regions."
|
||||
(let* ((root (treesit-buffer-root-node))
|
||||
(node (treesit-node-descendant-for-range root (region-beginning) (region-end)))
|
||||
(node-start (treesit-node-start node))
|
||||
(node-end (treesit-node-end node)))
|
||||
;; Node fits the region exactly. Try its parent node instead.
|
||||
(when (and (= (region-beginning) node-start) (= (region-end) node-end))
|
||||
(when-let* ((node (treesit-node-parent node)))
|
||||
(setq node-start (treesit-node-start node)
|
||||
node-end (treesit-node-end node))))
|
||||
(set-mark node-end)
|
||||
(goto-char node-start)))
|
||||
(add-to-list 'er/try-expand-list 'treesit-mark-bigger-node)))
|
||||
|
||||
;; avy中文支持
|
||||
(use-package ace-pinyin
|
||||
:init (ace-pinyin-global-mode +1))
|
||||
|
||||
;; avy-zap
|
||||
(use-package avy-zap
|
||||
:bind (("M-z" . avy-zap-to-char-dwim)
|
||||
("M-Z" . avy-zap-up-to-char-dwim)))
|
||||
|
||||
;; jinx,拼写检查
|
||||
(unless *is-windows*
|
||||
(use-package jinx
|
||||
@@ -153,6 +277,13 @@
|
||||
;; consult-flycheck
|
||||
(use-package consult-flycheck)
|
||||
|
||||
;; markdown
|
||||
(use-package markdown-mode
|
||||
:mode ("README\\.md\\'" . gfm-mode)
|
||||
:init (setq markdown-command "multimarkdown")
|
||||
:bind (:map markdown-mode-map
|
||||
("C-c C-e" . markdown-do)))
|
||||
|
||||
;; 安装emms
|
||||
(use-package emms
|
||||
:init
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
;; 自定义scratch
|
||||
(setq initial-scratch-message
|
||||
";; SCRATCH SCRATCH SCRATCH\n\n")
|
||||
"")
|
||||
|
||||
;; 开启server mode
|
||||
(server-start)
|
||||
@@ -68,6 +68,28 @@
|
||||
(add-hook 'emacs-lisp-mode-hook 'electric-pair-mode)
|
||||
(add-hook 'org-mode-hook 'electric-pair-mode)
|
||||
|
||||
;; short anwser
|
||||
(if (boundp 'use-short-answers)
|
||||
(setq use-short-answers t)
|
||||
(fset 'yes-or-no-p 'y-or-n-p))
|
||||
(setq-default major-mode 'text-mode
|
||||
fill-column 100
|
||||
tab-width 4
|
||||
indent-tabs-mode nil)
|
||||
|
||||
(setq visible-bell t
|
||||
inhibit-compacting-font-caches t ; Don’t compact font caches during GC
|
||||
delete-by-moving-to-trash t ; Deleting files go to OS's trash folder
|
||||
make-backup-files nil ; Forbide to make backup files
|
||||
auto-save-default nil ; Disable auto save
|
||||
|
||||
uniquify-buffer-name-style 'post-forward-angle-brackets ; Show path if names are same
|
||||
adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*"
|
||||
adaptive-fill-first-line-regexp "^* *$"
|
||||
sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*"
|
||||
sentence-end-double-space nil
|
||||
word-wrap-by-category t)
|
||||
|
||||
(provide 'init-startup)
|
||||
|
||||
;;; init-startup.el ends here
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
my-base16-dark-core-palette
|
||||
'((custom-theme-set-faces
|
||||
theme-name
|
||||
`(org-level-2 ((,class (:foreground ,blue :height 1.05))))
|
||||
`(org-level-3 ((,class (:foreground ,green))))
|
||||
`(org-level-6 ((,class (:foreground ,blue))))
|
||||
`(org-level-8 ((,class (:foreground ,green))))
|
||||
`(org-priority ((,class (:foreground ,blue :weight bold))))
|
||||
`(org-done ((,class (:foreground ,blue :weight bold))))
|
||||
`(org-headline-done ((,class (:foreground ,blue))))
|
||||
`(org-priority ((,class (:foreground ,green :weight bold))))
|
||||
`(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold))))
|
||||
`(font-lock-doc-face ((,class (:foreground ,green :slant normal))))
|
||||
`(font-lock-string-face ((,class (:foreground ,green))))
|
||||
`(dashboard-footer-face ((,class (:foreground ,blue))))
|
||||
`(dashboard-text-banner ((,class (:foreground ,green))))
|
||||
`(vertico-current ((,class (:background ,base02 :extend t :underline nil)))))))
|
||||
|
||||
(provide-theme 'my-base16-dark)
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
"#d33682" ; magenta: 品红
|
||||
"#6c71c4" ; violet: 紫罗兰
|
||||
"#2570CD" ; blue: 蓝色
|
||||
"#3A9C36" ; cyan: 青色
|
||||
"#01928D")) ; green: 绿色
|
||||
"#01928D" ; cyan: 青色
|
||||
"#3A9C36")) ; green: 绿色
|
||||
|
||||
(provide 'my-base16-palette)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user