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-window)
|
||||||
(require 'init-kbd)
|
(require 'init-kbd)
|
||||||
(require 'init-ui)
|
(require 'init-ui)
|
||||||
|
(require 'init-dashboard)
|
||||||
(require 'init-segmentation)
|
(require 'init-segmentation)
|
||||||
|
|
||||||
;;; init.el ends here
|
;;; init.el ends here
|
||||||
|
|||||||
@@ -13,23 +13,49 @@
|
|||||||
|
|
||||||
;; corfu
|
;; corfu
|
||||||
(use-package corfu
|
(use-package corfu
|
||||||
:init
|
:autoload (corfu-quit consult-completion-in-region)
|
||||||
(global-corfu-mode)
|
:functions (persistent-scratch-save corfu-move-to-minibuffer)
|
||||||
(corfu-history-mode)
|
|
||||||
(corfu-popupinfo-mode)
|
|
||||||
(corfu-echo-mode)
|
|
||||||
|
|
||||||
:custom
|
:custom
|
||||||
(corfu-auto t)
|
(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-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
|
:config
|
||||||
(:map corfu-map
|
;;Quit completion before saving
|
||||||
("RET" . nil)))
|
(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打开补全
|
;; 在eshell中使用tab打开补全
|
||||||
(add-hook 'eshell-mode-hook
|
(add-hook 'eshell-mode-hook
|
||||||
@@ -37,6 +63,9 @@
|
|||||||
(setq-local corfu-auto nil)
|
(setq-local corfu-auto nil)
|
||||||
(local-set-key (kbd "TAB") 'completion-at-point)))
|
(local-set-key (kbd "TAB") 'completion-at-point)))
|
||||||
|
|
||||||
|
(use-package nerd-icons-completion
|
||||||
|
:hook (marginalia-mode . nerd-icons-completion-marginalia-setup))
|
||||||
|
|
||||||
(use-package emacs
|
(use-package emacs
|
||||||
:custom
|
:custom
|
||||||
(tab-always-indent 'complete)
|
(tab-always-indent 'complete)
|
||||||
@@ -52,10 +81,23 @@
|
|||||||
|
|
||||||
;; cape
|
;; cape
|
||||||
(use-package 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
|
:init
|
||||||
(add-to-list 'completion-at-point-functions #'cape-file) ;; 文件补全
|
;; (add-to-list 'completion-at-point-functions #'cape-dabbrev)
|
||||||
(setq-local completion-at-point-functions
|
(add-to-list 'completion-at-point-functions #'cape-file)
|
||||||
(list (cape-capf-super #'cape-dabbrev)))) ;; 启用dabbrev
|
(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
|
;; lua
|
||||||
(use-package lua-ts-mode
|
(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"
|
(list "d"
|
||||||
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
|
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
|
||||||
"show diff between the buffer and its file"))
|
"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相关
|
;; org-mode相关
|
||||||
;; cycle当前subtree
|
;; 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)
|
(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)
|
(provide 'init-kbd)
|
||||||
|
|
||||||
;;; init-kbd.el ends here
|
;;; init-kbd.el ends here
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
(format-time-string "%a" time)
|
(format-time-string "%a" time)
|
||||||
(format-time-string "%Y-%m-%d %a" time)))
|
(format-time-string "%Y-%m-%d %a" time)))
|
||||||
org-journal-carryover-items "TODO=\"TODO\"|TODO=\"STARTED\"|TODO=\"WAITING\"|TODO=\"SOMEDAY\"")
|
org-journal-carryover-items "TODO=\"TODO\"|TODO=\"STARTED\"|TODO=\"WAITING\"|TODO=\"SOMEDAY\"")
|
||||||
|
|
||||||
(when *is-windows*
|
(when *is-windows*
|
||||||
(setq org-journal-dir "D:/emacs/my-org-daily/"))
|
(setq org-journal-dir "D:/emacs/my-org-daily/"))
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@
|
|||||||
(goto-char day-end)
|
(goto-char day-end)
|
||||||
(insert "\n\n** daily\n\n\n")
|
(insert "\n\n** daily\n\n\n")
|
||||||
(insert "** tasks\n")))))
|
(insert "** tasks\n")))))
|
||||||
|
|
||||||
(add-hook 'org-journal-after-header-create-hook #'my/journal-setup-new-day)
|
(add-hook 'org-journal-after-header-create-hook #'my/journal-setup-new-day)
|
||||||
|
|
||||||
(defun my/journal-position-cursor-after-time ()
|
(defun my/journal-position-cursor-after-time ()
|
||||||
(when (derived-mode-p 'org-journal-mode)
|
(when (derived-mode-p 'org-journal-mode)
|
||||||
(org-back-to-heading)
|
(org-back-to-heading)
|
||||||
(end-of-line)))
|
(end-of-line)))
|
||||||
|
|
||||||
(add-hook 'org-journal-after-entry-create-hook #'my/journal-position-cursor-after-time)
|
(add-hook 'org-journal-after-entry-create-hook #'my/journal-position-cursor-after-time)
|
||||||
|
|
||||||
(defun org-journal-open-entry-for-editing (&optional event)
|
(defun org-journal-open-entry-for-editing (&optional event)
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
(add-hook 'org-journal-mode-hook
|
(add-hook 'org-journal-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(global-cns-mode-enable-in-buffer)))
|
(global-cns-mode-enable-in-buffer)))
|
||||||
|
|
||||||
;; 一些随org-mode加载的基础配置
|
;; 一些随org-mode加载的基础配置
|
||||||
(add-hook 'org-mode-hook
|
(add-hook 'org-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
@@ -156,8 +156,7 @@
|
|||||||
(when *is-windows*
|
(when *is-windows*
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(setq org-agenda-files '("d:/emacs/hugo/this-is-my-blog/all-blog.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/"))))
|
||||||
"d:/emacs/my-org-daily/"))))
|
|
||||||
(when *is-mac*
|
(when *is-mac*
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(setq org-agenda-files '("~/org/my-org-daily"))))
|
(setq org-agenda-files '("~/org/my-org-daily"))))
|
||||||
@@ -271,18 +270,18 @@ See `org-capture-templates' for more information."
|
|||||||
(let* ((blog-dir "d:/emacs/hugo/this-is-my-blog/")
|
(let* ((blog-dir "d:/emacs/hugo/this-is-my-blog/")
|
||||||
(timestamp (format-time-string "%Y-%m-%d %H:%M:%S"))
|
(timestamp (format-time-string "%Y-%m-%d %H:%M:%S"))
|
||||||
(default-directory blog-dir))
|
(default-directory blog-dir))
|
||||||
|
|
||||||
;; save buffer
|
;; save buffer
|
||||||
(save-buffer)
|
(save-buffer)
|
||||||
|
|
||||||
;; git add
|
;; git add
|
||||||
(message "Adding files...")
|
(message "Adding files...")
|
||||||
(eshell-command "git add .")
|
(eshell-command "git add .")
|
||||||
|
|
||||||
;; git commit with timestamp
|
;; git commit with timestamp
|
||||||
(message "Committing: %s" timestamp)
|
(message "Committing: %s" timestamp)
|
||||||
(eshell-command (format "git commit -m \"Update: %s\"" timestamp))
|
(eshell-command (format "git commit -m \"Update: %s\"" timestamp))
|
||||||
|
|
||||||
;; git push
|
;; git push
|
||||||
(message "Pushing to remote...")
|
(message "Pushing to remote...")
|
||||||
(let ((exit-code (eshell-command "git push")))
|
(let ((exit-code (eshell-command "git push")))
|
||||||
|
|||||||
@@ -8,12 +8,53 @@
|
|||||||
|
|
||||||
;; 安装gcmh用于管理内存回收
|
;; 安装gcmh用于管理内存回收
|
||||||
(use-package gcmh
|
(use-package gcmh
|
||||||
|
:demand t
|
||||||
:init
|
:init
|
||||||
(setq gcmh-idle-delay 5 ; 空闲 5 秒后 GC
|
(setq gcmh-idle-delay 'auto
|
||||||
gcmh-high-cons-threshold (* 16 1024 1024)) ; 高阈值 16MB
|
gcmh-auto-idle-delay-factor 10
|
||||||
|
gcmh-high-cons-threshold #x4000000)
|
||||||
:config
|
:config
|
||||||
(gcmh-mode 1))
|
(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)
|
(use-package restart-emacs)
|
||||||
|
|
||||||
;; 安装multiple-cursors
|
;; 安装multiple-cursors
|
||||||
@@ -49,7 +90,7 @@
|
|||||||
;; 安装consult,增强搜索和其他菜单
|
;; 安装consult,增强搜索和其他菜单
|
||||||
(use-package consult
|
(use-package consult
|
||||||
:config
|
:config
|
||||||
|
|
||||||
(defun consult-fd-global ()
|
(defun consult-fd-global ()
|
||||||
"Search for all files use fd"
|
"Search for all files use fd"
|
||||||
(interactive)
|
(interactive)
|
||||||
@@ -65,9 +106,69 @@
|
|||||||
(when *is-mac*
|
(when *is-mac*
|
||||||
(setopt consult-locate-args "mdfind -name")))
|
(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
|
(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
|
;; 安装embark-consult和wgrep
|
||||||
(use-package embark-consult)
|
(use-package embark-consult)
|
||||||
@@ -83,6 +184,9 @@
|
|||||||
'embark-collect-mode-hook
|
'embark-collect-mode-hook
|
||||||
#'consult-preview-at-point-mode))))
|
#'consult-preview-at-point-mode))))
|
||||||
|
|
||||||
|
;; nerd-icon
|
||||||
|
(use-package nerd-icons)
|
||||||
|
|
||||||
;; 启用savehist,保存命令顺序
|
;; 启用savehist,保存命令顺序
|
||||||
(use-package savehist
|
(use-package savehist
|
||||||
:hook (after-init . savehist-mode)
|
:hook (after-init . savehist-mode)
|
||||||
@@ -116,16 +220,36 @@
|
|||||||
|
|
||||||
;; ibuffer-projectile
|
;; ibuffer-projectile
|
||||||
(use-package ibuffer-projectile
|
(use-package ibuffer-projectile
|
||||||
:init (add-hook 'ibuffer-hook
|
:config (add-hook 'ibuffer-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(ibuffer-projectile-set-filter-groups)
|
(ibuffer-projectile-set-filter-groups)
|
||||||
(unless (eq ibuffer-sorting-mode 'alphabetic)
|
(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中文支持
|
;; avy中文支持
|
||||||
(use-package ace-pinyin
|
(use-package ace-pinyin
|
||||||
:init (ace-pinyin-global-mode +1))
|
: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,拼写检查
|
;; jinx,拼写检查
|
||||||
(unless *is-windows*
|
(unless *is-windows*
|
||||||
(use-package jinx
|
(use-package jinx
|
||||||
@@ -153,22 +277,29 @@
|
|||||||
;; consult-flycheck
|
;; consult-flycheck
|
||||||
(use-package 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
|
;; 安装emms
|
||||||
(use-package emms
|
(use-package emms
|
||||||
:init
|
:init
|
||||||
;; 设置音乐文件默认目录
|
;; 设置音乐文件默认目录
|
||||||
(when *is-windows*
|
(when *is-windows*
|
||||||
(setq emms-source-file-default-directory "F:/luping26-1-11/"))
|
(setq emms-source-file-default-directory "F:/luping26-1-11/"))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
;; --- 基础设置 ---
|
;; --- 基础设置 ---
|
||||||
(require 'emms-setup)
|
(require 'emms-setup)
|
||||||
(emms-all) ; 加载所有稳定功能
|
(emms-all) ; 加载所有稳定功能
|
||||||
|
|
||||||
;; 使用简单模式的 mpv 播放器
|
;; 使用简单模式的 mpv 播放器
|
||||||
;; 移除默认的 emms-player-mpv
|
;; 移除默认的 emms-player-mpv
|
||||||
(require 'emms-player-simple)
|
(require 'emms-player-simple)
|
||||||
|
|
||||||
;; 定义简单的 mpv 播放器
|
;; 定义简单的 mpv 播放器
|
||||||
(define-emms-simple-player mpv-simple '(file url streamlist playlist)
|
(define-emms-simple-player mpv-simple '(file url streamlist playlist)
|
||||||
(concat "\\.\\("
|
(concat "\\.\\("
|
||||||
@@ -186,41 +317,41 @@
|
|||||||
"--keep-open=yes"
|
"--keep-open=yes"
|
||||||
"--fs=no"
|
"--fs=no"
|
||||||
"--quiet")
|
"--quiet")
|
||||||
|
|
||||||
;; 设置播放器列表
|
;; 设置播放器列表
|
||||||
(setq emms-player-list '(emms-player-mpv-simple
|
(setq emms-player-list '(emms-player-mpv-simple
|
||||||
emms-player-vlc
|
emms-player-vlc
|
||||||
emms-player-mplayer))
|
emms-player-mplayer))
|
||||||
|
|
||||||
(setq emms-playlist-default-playlist-name "*EMMS Playlist*")
|
(setq emms-playlist-default-playlist-name "*EMMS Playlist*")
|
||||||
(setq emms-playlist-buffer-name "*EMMS Playlist*")
|
(setq emms-playlist-buffer-name "*EMMS Playlist*")
|
||||||
|
|
||||||
;; 使用更快的文件查找方法(windows上需要使用internal)
|
;; 使用更快的文件查找方法(windows上需要使用internal)
|
||||||
;; (setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
|
;; (setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
|
||||||
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-internal)
|
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-internal)
|
||||||
|
|
||||||
;; 使用原生 Elisp 元数据读取器
|
;; 使用原生 Elisp 元数据读取器
|
||||||
(setq emms-info-functions '(emms-info-native))
|
(setq emms-info-functions '(emms-info-native))
|
||||||
|
|
||||||
;; 异步读取元数据
|
;; 异步读取元数据
|
||||||
(setq emms-info-asynchronously t)
|
(setq emms-info-asynchronously t)
|
||||||
|
|
||||||
;; 使用更详细的曲目描述
|
;; 使用更详细的曲目描述
|
||||||
(setq emms-track-description-function #'emms-info-track-description)
|
(setq emms-track-description-function #'emms-info-track-description)
|
||||||
|
|
||||||
;; 模式行设置
|
;; 模式行设置
|
||||||
(require 'emms-mode-line)
|
(require 'emms-mode-line)
|
||||||
(emms-mode-line-mode 1)
|
(emms-mode-line-mode 1)
|
||||||
(emms-mode-line-blank) ; 初始为空
|
(emms-mode-line-blank) ; 初始为空
|
||||||
|
|
||||||
;; 自定义模式行格式
|
;; 自定义模式行格式
|
||||||
(setq emms-mode-line-format " [%s] ")
|
(setq emms-mode-line-format " [%s] ")
|
||||||
(setq emms-mode-line-length-limit 60)
|
(setq emms-mode-line-length-limit 60)
|
||||||
|
|
||||||
;; 播放时间显示
|
;; 播放时间显示
|
||||||
(require 'emms-playing-time)
|
(require 'emms-playing-time)
|
||||||
(emms-playing-time-mode 1)
|
(emms-playing-time-mode 1)
|
||||||
|
|
||||||
;; 歌词设置
|
;; 歌词设置
|
||||||
(require 'emms-lyrics)
|
(require 'emms-lyrics)
|
||||||
(setq emms-lyrics-display-on-modeline t) ; 在模式行显示歌词
|
(setq emms-lyrics-display-on-modeline t) ; 在模式行显示歌词
|
||||||
@@ -231,60 +362,60 @@
|
|||||||
(setq emms-lyrics-dir "~/Music/lyrics") ; 歌词文件目录
|
(setq emms-lyrics-dir "~/Music/lyrics") ; 歌词文件目录
|
||||||
(setq emms-lyrics-display-format " %s ") ; 歌词显示格式
|
(setq emms-lyrics-display-format " %s ") ; 歌词显示格式
|
||||||
(emms-lyrics 1) ; 启用歌词显示
|
(emms-lyrics 1) ; 启用歌词显示
|
||||||
|
|
||||||
;; 浏览器设置
|
;; 浏览器设置
|
||||||
(require 'emms-browser)
|
(require 'emms-browser)
|
||||||
(setq emms-browser-default-browse-type 'artist)
|
(setq emms-browser-default-browse-type 'artist)
|
||||||
(setq emms-browser-covers nil) ; 禁用封面
|
(setq emms-browser-covers nil) ; 禁用封面
|
||||||
|
|
||||||
;; 浏览器显示格式
|
;; 浏览器显示格式
|
||||||
(setq emms-browser-info-title-format "%i%n")
|
(setq emms-browser-info-title-format "%i%n")
|
||||||
(setq emms-browser-playlist-info-title-format "%i%n")
|
(setq emms-browser-playlist-info-title-format "%i%n")
|
||||||
|
|
||||||
;; 添加浏览器快捷键
|
;; 添加浏览器快捷键
|
||||||
(define-key emms-browser-mode-map (kbd "SPC") 'emms-browser-add-tracks-and-play)
|
(define-key emms-browser-mode-map (kbd "SPC") 'emms-browser-add-tracks-and-play)
|
||||||
|
|
||||||
;; 缓存设置
|
;; 缓存设置
|
||||||
(require 'emms-cache)
|
(require 'emms-cache)
|
||||||
(emms-cache 1) ; 启用缓存
|
(emms-cache 1) ; 启用缓存
|
||||||
|
|
||||||
;; 历史记录
|
;; 历史记录
|
||||||
(require 'emms-history)
|
(require 'emms-history)
|
||||||
(add-hook 'emms-player-started-hook #'emms-last-played-update-current)
|
(add-hook 'emms-player-started-hook #'emms-last-played-update-current)
|
||||||
|
|
||||||
;; 音量控制
|
;; 音量控制
|
||||||
(require 'emms-volume)
|
(require 'emms-volume)
|
||||||
;; 在播放列表中使用 +/- 控制音量
|
;; 在播放列表中使用 +/- 控制音量
|
||||||
(define-key emms-playlist-mode-map (kbd "+") #'emms-volume-raise)
|
(define-key emms-playlist-mode-map (kbd "+") #'emms-volume-raise)
|
||||||
(define-key emms-playlist-mode-map (kbd "-") #'emms-volume-lower)
|
(define-key emms-playlist-mode-map (kbd "-") #'emms-volume-lower)
|
||||||
|
|
||||||
;; 添加(playlist中的)快捷键
|
;; 添加(playlist中的)快捷键
|
||||||
(define-key emms-playlist-mode-map (kbd "SPC") 'emms-pause)
|
(define-key emms-playlist-mode-map (kbd "SPC") 'emms-pause)
|
||||||
(define-key emms-playlist-mode-map (kbd "N") 'emms-next)
|
(define-key emms-playlist-mode-map (kbd "N") 'emms-next)
|
||||||
(define-key emms-playlist-mode-map (kbd "P") 'emms-previous)
|
(define-key emms-playlist-mode-map (kbd "P") 'emms-previous)
|
||||||
(define-key emms-playlist-mode-map (kbd "R") 'emms-random)
|
(define-key emms-playlist-mode-map (kbd "R") 'emms-random)
|
||||||
(define-key emms-playlist-mode-map (kbd "/") 'emms-playlist-limit)
|
(define-key emms-playlist-mode-map (kbd "/") 'emms-playlist-limit)
|
||||||
|
|
||||||
;; 启用标记功能
|
;; 启用标记功能
|
||||||
(require 'emms-mark)
|
(require 'emms-mark)
|
||||||
|
|
||||||
;; 启用播放列表排序
|
;; 启用播放列表排序
|
||||||
(require 'emms-playlist-sort)
|
(require 'emms-playlist-sort)
|
||||||
(define-key emms-playlist-mode-map (kbd "S s") 'emms-playlist-sort-map)
|
(define-key emms-playlist-mode-map (kbd "S s") 'emms-playlist-sort-map)
|
||||||
|
|
||||||
;; 启用播放列表限制/过滤
|
;; 启用播放列表限制/过滤
|
||||||
(require 'emms-playlist-limit)
|
(require 'emms-playlist-limit)
|
||||||
|
|
||||||
;; 启用标签编辑器
|
;; 启用标签编辑器
|
||||||
(require 'emms-tag-editor)
|
(require 'emms-tag-editor)
|
||||||
|
|
||||||
;; 启用评分系统
|
;; 启用评分系统
|
||||||
(require 'emms-score)
|
(require 'emms-score)
|
||||||
(emms-score 1)
|
(emms-score 1)
|
||||||
|
|
||||||
;; 启动后自动恢复播放列表
|
;; 启动后自动恢复播放列表
|
||||||
;; (add-hook 'after-init-hook 'emms-history-load)
|
;; (add-hook 'after-init-hook 'emms-history-load)
|
||||||
|
|
||||||
;; 显示加载完成消息
|
;; 显示加载完成消息
|
||||||
(message "EMMS loaded")
|
(message "EMMS loaded")
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
;; 自定义scratch
|
;; 自定义scratch
|
||||||
(setq initial-scratch-message
|
(setq initial-scratch-message
|
||||||
";; SCRATCH SCRATCH SCRATCH\n\n")
|
"")
|
||||||
|
|
||||||
;; 开启server mode
|
;; 开启server mode
|
||||||
(server-start)
|
(server-start)
|
||||||
@@ -68,6 +68,28 @@
|
|||||||
(add-hook 'emacs-lisp-mode-hook 'electric-pair-mode)
|
(add-hook 'emacs-lisp-mode-hook 'electric-pair-mode)
|
||||||
(add-hook 'org-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)
|
(provide 'init-startup)
|
||||||
|
|
||||||
;;; init-startup.el ends here
|
;;; init-startup.el ends here
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
(choice (completing-read
|
(choice (completing-read
|
||||||
"Color: "
|
"Color: "
|
||||||
(mapcar (lambda (c)
|
(mapcar (lambda (c)
|
||||||
(propertize
|
(propertize
|
||||||
(format "%-20s %s" c "████")
|
(format "%-20s %s" c "████")
|
||||||
'face `(:foreground ,c)))
|
'face `(:foreground ,c)))
|
||||||
colors))))
|
colors))))
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
(setenv "COLORTERM" "truecolor")
|
(setenv "COLORTERM" "truecolor")
|
||||||
(add-to-list 'eshell-output-filter-functions 'eshell-handle-ansi-color t)
|
(add-to-list 'eshell-output-filter-functions 'eshell-handle-ansi-color t)
|
||||||
(setq-local eshell-prefer-lisp-functions nil)
|
(setq-local eshell-prefer-lisp-functions nil)
|
||||||
(setenv "LS_COLORS"
|
(setenv "LS_COLORS"
|
||||||
"di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46")
|
"di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46")
|
||||||
(setenv "GIT_CONFIG_GLOBAL" (expand-file-name "~/.emacs.d/.gitconfig-eshell"))))
|
(setenv "GIT_CONFIG_GLOBAL" (expand-file-name "~/.emacs.d/.gitconfig-eshell"))))
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,12 @@
|
|||||||
my-base16-dark-core-palette
|
my-base16-dark-core-palette
|
||||||
'((custom-theme-set-faces
|
'((custom-theme-set-faces
|
||||||
theme-name
|
theme-name
|
||||||
`(org-level-2 ((,class (:foreground ,blue :height 1.05))))
|
`(org-priority ((,class (:foreground ,green :weight bold))))
|
||||||
`(org-level-3 ((,class (:foreground ,green))))
|
`(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold))))
|
||||||
`(org-level-6 ((,class (:foreground ,blue))))
|
`(font-lock-doc-face ((,class (:foreground ,green :slant normal))))
|
||||||
`(org-level-8 ((,class (:foreground ,green))))
|
`(font-lock-string-face ((,class (:foreground ,green))))
|
||||||
`(org-priority ((,class (:foreground ,blue :weight bold))))
|
`(dashboard-footer-face ((,class (:foreground ,blue))))
|
||||||
`(org-done ((,class (:foreground ,blue :weight bold))))
|
`(dashboard-text-banner ((,class (:foreground ,green))))
|
||||||
`(org-headline-done ((,class (:foreground ,blue))))
|
|
||||||
`(vertico-current ((,class (:background ,base02 :extend t :underline nil)))))))
|
`(vertico-current ((,class (:background ,base02 :extend t :underline nil)))))))
|
||||||
|
|
||||||
(provide-theme 'my-base16-dark)
|
(provide-theme 'my-base16-dark)
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
"#d33682" ; magenta: 品红
|
"#d33682" ; magenta: 品红
|
||||||
"#6c71c4" ; violet: 紫罗兰
|
"#6c71c4" ; violet: 紫罗兰
|
||||||
"#2570CD" ; blue: 蓝色
|
"#2570CD" ; blue: 蓝色
|
||||||
"#3A9C36" ; cyan: 青色
|
"#01928D" ; cyan: 青色
|
||||||
"#01928D")) ; green: 绿色
|
"#3A9C36")) ; green: 绿色
|
||||||
|
|
||||||
(provide 'my-base16-palette)
|
(provide 'my-base16-palette)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user