Config: add TUI support: split GUI/terminal config, add init-terminal-{package,ui,kbd}
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
;; 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
|
||||
|
||||
46
init.el
46
init.el
@@ -15,22 +15,34 @@
|
||||
|
||||
(global-display-line-numbers-mode t)
|
||||
|
||||
(require 'init-const)
|
||||
(load "init-proxy" t)
|
||||
(require 'init-startup)
|
||||
(require 'init-elpa)
|
||||
(require 'init-package)
|
||||
(require 'init-emms)
|
||||
(require 'init-org)
|
||||
(require 'init-prog)
|
||||
(require 'init-completion)
|
||||
(require 'init-window)
|
||||
(require 'init-exwm)
|
||||
(require 'init-dired)
|
||||
(require 'init-gptel)
|
||||
(require 'init-ui)
|
||||
(require 'init-kbd-func)
|
||||
(require 'init-kbd)
|
||||
(require 'init-segmentation)
|
||||
(if (display-graphic-p)
|
||||
(progn
|
||||
(require 'init-const)
|
||||
(load "init-proxy" t)
|
||||
(require 'init-startup)
|
||||
(require 'init-elpa)
|
||||
(require 'init-package)
|
||||
(require 'init-emms)
|
||||
(require 'init-org)
|
||||
(require 'init-prog)
|
||||
(require 'init-completion)
|
||||
(require 'init-window)
|
||||
(require 'init-exwm)
|
||||
(require 'init-dired)
|
||||
(require 'init-gptel)
|
||||
(require 'init-ui)
|
||||
(require 'init-kbd-func)
|
||||
(require 'init-kbd)
|
||||
(require 'init-segmentation))
|
||||
(progn
|
||||
(require 'init-const)
|
||||
(load "init-proxy" t)
|
||||
(require 'init-startup)
|
||||
(require 'init-elpa)
|
||||
(require 'init-terminal-package)
|
||||
(require 'init-prog)
|
||||
(require 'init-terminal-ui)
|
||||
(require 'init-terminal-kbd)
|
||||
(require 'init-segmentation)))
|
||||
|
||||
;;; init.el ends here
|
||||
|
||||
@@ -47,8 +47,9 @@
|
||||
(global-auto-revert-mode 1)
|
||||
|
||||
;; 开启recent file mode
|
||||
(recentf-mode)
|
||||
(setq recentf-max-saved-items 30) ;; 最大保存数量
|
||||
(when (display-graphic-p)
|
||||
(recentf-mode)
|
||||
(setq recentf-max-saved-items 30)) ;; 最大保存数量
|
||||
|
||||
;; 启用select delete
|
||||
(delete-selection-mode)
|
||||
|
||||
156
lisp/init-terminal-kbd.el
Normal file
156
lisp/init-terminal-kbd.el
Normal file
@@ -0,0 +1,156 @@
|
||||
;;; init-terminal-kbd.el --- keybindings -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; 修改mac键位
|
||||
(when *is-mac*
|
||||
(setq mac-command-modifier 'meta)
|
||||
(setq mac-option-modifier 'none))
|
||||
|
||||
(defun open-init-file()
|
||||
"Open user's init.el file in ~/.emacs.d ."
|
||||
(interactive)
|
||||
(find-file "~/.emacs.d/init.el"))
|
||||
|
||||
(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)
|
||||
(popper-toggle-type)
|
||||
(delete-other-windows))
|
||||
|
||||
;; scratch buffer
|
||||
(if *is-mac*
|
||||
(general-def "C-c <f12>" 'scratch-buffer)
|
||||
(general-def "C-c <delete>" 'scratch-buffer))
|
||||
|
||||
;; markdown
|
||||
(general-def markdown-mode-map
|
||||
"M-p" nil
|
||||
"M-n" nil)
|
||||
|
||||
;; org-mode
|
||||
(general-def org-mode-map
|
||||
"C-<tab>" 'org-cycle-current-subtree
|
||||
"C-c o l" 'org-toggle-link-display)
|
||||
|
||||
;; global map with C-c prefix
|
||||
(general-def
|
||||
:prefix "C-c"
|
||||
"c" 'hydra-multiple-cursors/body
|
||||
"e" 'er/expand-region
|
||||
"k" 'comment-line)
|
||||
|
||||
;; global map
|
||||
(general-def
|
||||
|
||||
;; buffer, file, and window
|
||||
"<f2>" 'open-init-file
|
||||
"M-[" 'previous-buffer
|
||||
"M-]" 'next-buffer
|
||||
"C-x C-b" 'ibuffer-other-window
|
||||
"C-x K" 'crux-kill-other-buffers
|
||||
|
||||
;; edit
|
||||
"M-c" 'capitalize-dwim
|
||||
"M-u" 'upcase-dwim
|
||||
"M-l" 'downcase-dwim
|
||||
"C-," 'duplicate-and-move-to-next-line
|
||||
"C-k" 'crux-smart-kill-line
|
||||
"C-<backspace>" 'crux-kill-line-backwards
|
||||
"C-o" 'open-line
|
||||
"C-a" 'crux-move-beginning-of-line
|
||||
"M-y" 'consult-yank-from-kill-ring
|
||||
"C-c <backspace>" 'hungry-delete-backward
|
||||
"C-c C-<backspace>" 'hungry-delete-forward
|
||||
"M-P" 'drag-stuff-up
|
||||
"M-N" 'drag-stuff-down
|
||||
|
||||
;; undo
|
||||
"C-/" 'undo-fu-only-undo
|
||||
"C-?" 'undo-fu-only-redo
|
||||
|
||||
;; navigate
|
||||
"M-p" 'backward-paragraph
|
||||
"M-n" 'forward-paragraph
|
||||
"<mouse-2>" 'xref-find-definitions-at-mouse
|
||||
"C-M-;" 'avy-goto-char
|
||||
"C-M-'" 'avy-goto-word-1
|
||||
"M-g g" 'avy-goto-line
|
||||
|
||||
;; window
|
||||
"M-<left>" 'shrink-window-horizontally
|
||||
"M-<right>" 'enlarge-window-horizontally
|
||||
"M-<down>" 'shrink-window
|
||||
"M-<up>" 'enlarge-window
|
||||
"M-`" 'popper-toggle
|
||||
"C-M-=" 'popper-toggle-type-delete-other-window
|
||||
"M-o" 'other-window
|
||||
"<f10>" 'esw/swap-two-windows
|
||||
|
||||
;; other
|
||||
"<mouse-3>" 'global-tab-line-mode)
|
||||
|
||||
;; expand region
|
||||
(setq expand-region-reset-fast-key "r")
|
||||
(setq expand-region-contract-fast-key "c")
|
||||
|
||||
;; save-some-buffer时diff更改
|
||||
(add-to-list 'save-some-buffers-action-alist
|
||||
(list "d"
|
||||
(lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer)))
|
||||
"show diff between the buffer and its file"))
|
||||
|
||||
;; hydra
|
||||
(use-package hydra
|
||||
:defines (consult-imenu-config)
|
||||
:init
|
||||
(with-eval-after-load 'consult-imenu
|
||||
(setq consult-imenu-config
|
||||
'((emacs-lisp-mode :toplevel "Functions"
|
||||
:types ((?f "Functions" font-lock-function-name-face)
|
||||
(?h "Hydras" font-lock-constant-face)
|
||||
(?m "Macros" font-lock-function-name-face)
|
||||
(?p "Packages" font-lock-constant-face)
|
||||
(?t "Types" font-lock-type-face)
|
||||
(?v "Variables" font-lock-variable-name-face)))))))
|
||||
|
||||
;; multiple-cursors
|
||||
(defhydra hydra-multiple-cursors ()
|
||||
"
|
||||
^Mark^ ^Unmark^ ^Other^
|
||||
------------------------------------------------------------------
|
||||
_p_ : prev line _P_ : previous _c_ : edit lines
|
||||
_n_ : next line _N_ : next _._ : pop
|
||||
_b_ : prev word _q_ : quit
|
||||
_f_ : next word
|
||||
_B_ : prev symbol
|
||||
_F_ : next symbol
|
||||
_s_ : in region
|
||||
_a_ : all dwim
|
||||
"
|
||||
("p" mc/mark-previous-like-this)
|
||||
("n" mc/mark-next-like-this)
|
||||
("b" mc/mark-previous-like-this-word)
|
||||
("f" mc/mark-next-like-this-word)
|
||||
("B" mc/mark-previous-like-this-symbol)
|
||||
("F" mc/mark-next-like-this-symbol)
|
||||
("P" mc/unmark-previous-like-this)
|
||||
("N" mc/unmark-next-like-this)
|
||||
("a" mc/mark-all-dwim)
|
||||
("s" mc/mark-all-in-region)
|
||||
("c" mc/edit-lines)
|
||||
("." mc/mark-pop)
|
||||
("q" nil))
|
||||
|
||||
(provide 'init-terminal-kbd)
|
||||
|
||||
;;; init-terminal-kbd.el ends here
|
||||
62
lisp/init-terminal-package.el
Normal file
62
lisp/init-terminal-package.el
Normal file
@@ -0,0 +1,62 @@
|
||||
;;; init-terminal-package.el --- major packages -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; 安装gcmh用于管理内存回收
|
||||
(use-package gcmh
|
||||
:demand t
|
||||
:init
|
||||
(setq gcmh-idle-delay 'auto
|
||||
gcmh-auto-idle-delay-factor 10
|
||||
gcmh-high-cons-threshold #x4000000)
|
||||
:config
|
||||
(gcmh-mode 1))
|
||||
|
||||
;; 安装multiple-cursors
|
||||
(use-package multiple-cursors)
|
||||
|
||||
;; 安装crux,增强快捷键,快捷键配置在init-kbd.el中
|
||||
(use-package crux)
|
||||
|
||||
;; 安装hungry-delete
|
||||
(use-package hungry-delete)
|
||||
|
||||
;; 安装drag-stuff,拖动字符
|
||||
(use-package drag-stuff)
|
||||
|
||||
;; 启用savehist,保存命令顺序
|
||||
(use-package savehist
|
||||
:init (setq enable-recursive-minibuffers t
|
||||
history-length 50
|
||||
savehist-additional-variables '(mark-ring
|
||||
global-mark-ring
|
||||
search-ring
|
||||
regexp-search-ring
|
||||
extended-command-history)
|
||||
savehist-autosave-interval 300)
|
||||
(savehist-mode))
|
||||
|
||||
;; saveplace,保存光标位置
|
||||
(use-package saveplace
|
||||
:init (save-place-mode))
|
||||
|
||||
;; undo增强
|
||||
(use-package undo-fu)
|
||||
|
||||
;; vundop,撤回树
|
||||
(use-package vundo
|
||||
:init (setq undo-limit 800000
|
||||
undo-strong-limit 1200000
|
||||
undo-outer-limit 12000000))
|
||||
|
||||
;; expand-region,快速展开选中
|
||||
(use-package expand-region)
|
||||
|
||||
;; general
|
||||
(use-package general)
|
||||
|
||||
(provide 'init-terminal-package)
|
||||
|
||||
;;; init-terminal-package.el ends here
|
||||
30
lisp/init-terminal-ui.el
Normal file
30
lisp/init-terminal-ui.el
Normal file
@@ -0,0 +1,30 @@
|
||||
;;; init-terminal-ui.el --- ui and other style customization cofig -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; 设置系统编码
|
||||
(when (fboundp 'set-charset-priority)
|
||||
(set-charset-priority 'unicode))
|
||||
|
||||
(if *is-windows*
|
||||
(progn
|
||||
(set-language-environment 'chinese-gbk)
|
||||
(prefer-coding-system 'utf-8-auto))
|
||||
(progn
|
||||
(set-language-environment "UTF-8")
|
||||
(prefer-coding-system 'utf-8)))
|
||||
|
||||
;; 高亮当前行
|
||||
(global-hl-line-mode t)
|
||||
|
||||
;; 显示文件大小
|
||||
(size-indication-mode t)
|
||||
|
||||
;; 显示行号列号
|
||||
(column-number-mode t)
|
||||
|
||||
(provide 'init-terminal-ui)
|
||||
|
||||
;;; init-terminal-ui.el ends here
|
||||
Reference in New Issue
Block a user