feat(emacs): evil, appearance and edit

* evil: Text Object (l -> inner) and Evil-Surround
* appearance: mode line (doom) and bufferline (built-in)
* edit: vertico and marginalia
This commit is contained in:
js0ny 2025-01-29 03:01:59 +00:00
parent ffcc8fb768
commit e6b1e1b595
8 changed files with 99 additions and 21 deletions

View file

@ -0,0 +1,29 @@
;;; init-appearance.el
(when (display-graphic-p)
(add-to-list 'default-frame-alist '(font . "JetBrainsMono NF")))
;; Icon Support
;; Once installed, Manually install the fonts required:
;; M-x all-the-icons-install-fonts
;; If under Microsoft Windows, the Installation Directory should be chosen
;; and right-click them to install the fonts
(use-package all-the-icons
:if (display-graphic-p))
(use-package catppuccin-theme
:config
(setq catppuccin-flavor 'mocha) ; This looks like shit in terminal mode
(load-theme 'catppuccin t))
;; Better mode line, see (L7) Icon install
;; M-x nerd-icons-install-fonts
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
(global-tab-line-mode) ; bufferline
(provide 'init-appearance)

View file

@ -14,13 +14,6 @@
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs
(server-mode 1)
(when (display-graphic-p)
(add-to-list 'default-frame-alist '(font . "JetBrainsMono NF")))
(use-package catppuccin-theme
:config
(setq catppuccin-flavor 'mocha) ; This looks like shit in terminal mode
(load-theme 'catppuccin t))
(require 'recentf)
(recentf-mode 1)

View file

@ -0,0 +1,22 @@
;;; init-edit.el
;; Company - Complete Anything
(use-package company
:ensure t
:hook (after-init . global-company-mode) ; 在启动后自动启用 global-company-mode
:bind (:map company-active-map ; TODO: Seems does not work
("C-n" . company-select-next)
("C-p" . company-select-previous))
:config
(setq company-minimum-prefix-length 1 ; 设置最短补全前缀
company-idle-delay 0.2)) ; 设置补全延迟(秒)
;; minibuffer 补全增强
(use-package vertico
:init
(vertico-mode))
;; 提供补全注解
(use-package marginalia
:init
(marginalia-mode))

View file

@ -22,6 +22,12 @@
"E" '(lambda () (interactive) (evil-previous-line 5)) ; 5e
))
;; Text Objects Keymap - Use `l` for inner (swap i and l)
;; https://github.com/emacs-evil/evil/blob/master/evil-maps.el#L398-L421
(define-key evil-visual-state-map "l" evil-inner-text-objects-map)
(define-key evil-operator-state-map "l" evil-inner-text-objects-map)
;; Provides Vim-like Leader key <SPC>
(use-package evil-leader
:after evil
@ -37,5 +43,11 @@
:config
(evil-commentary-mode))
;; Evil Surround: Vim-surround Evil fork
(use-package evil-surround
:after evil
:config
(global-evil-surround-mode 1))
(provide 'init-evil)

View file

@ -0,0 +1,24 @@
;;; init-file.el -- File Management configuration
;;; First edit at 2025/01/29
;; Dired
;; Dired Configuration
(with-eval-after-load 'dired
(setq dired-recursive-deletes 'top) ;; Ask Before Delete Dir
(setq dired-recursive-copies 'always) ;; Always Copy Dir
(setq dired-dwim-target t)) ;; dwim for Do What I Mean - 当分屏显示两个 Buffer 时,复制或移动文件会自动将另一个 dired buffer 作为目标目录
;; Dired Keybindings - Colemak
(evil-define-key 'normal dired-mode-map
"h" 'dired-up-directory
"i" 'dired-find-file
"n" 'dired-next-line
"e" 'dired-previous-line)
;; This prevents Dired from opening more buffers
;; https://stackoverflow.com/q/1839313
(setq dired-kill-when-opening-new-dired-buffer t)
(provide 'init-file)

View file

@ -4,7 +4,7 @@
(require 'package)
; Add sources
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu" . "https://elpa.gnu.org/packages/")))
;; Initialise the package management system
@ -15,14 +15,14 @@
(package-refresh-contents))
;; Ensure use-package is installed
(unless (package-installed-p 'use-package)
(unless (package-installed-p 'use-package)
; (package-refresh-contents) Move to above
(package-install 'use-package))
;; Use `use-package` for plugin management
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t)
(setq use-package-always-ensure t)
;; This part initialse the GPG Keyring
; Disable signature first
@ -33,16 +33,6 @@
; Re-enable signature
(setq package-check-signature 'allow-unsigned)
;; Company - Complete Anything
(use-package company
:ensure t
:hook (after-init . global-company-mode) ; 在启动后自动启用 global-company-mode
:bind (:map company-active-map ; TODO: Seems does not work
("C-n" . company-select-next)
("C-p" . company-select-previous))
:config
(setq company-minimum-prefix-length 1 ; 设置最短补全前缀
company-idle-delay 0.2)) ; 设置补全延迟(秒)
;; Which Key - Prompt available commands
(use-package which-key
@ -74,5 +64,11 @@
;
(use-package wakatime-mode
:ensure t
:config
(global-wakatime-mode))
(provide 'init-package)
;;; init-package.el ends here