mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(emacs-evil): Make emacs look like a Vim
This commit is contained in:
parent
5dc5ba0c5f
commit
ffcc8fb768
8 changed files with 114 additions and 8 deletions
2
tools/emacs.d/.gitignore
vendored
2
tools/emacs.d/.gitignore
vendored
|
|
@ -15,3 +15,5 @@ tutorial
|
||||||
# 自动保存的文件
|
# 自动保存的文件
|
||||||
auto-save-list
|
auto-save-list
|
||||||
tramp
|
tramp
|
||||||
|
|
||||||
|
recentf
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
'(package-selected-packages '(use-package evil company)))
|
'(package-selected-packages
|
||||||
|
'(gnu-elpa-keyring-update--keyring gnu-elpa-keyring-update lsp-mode catppuccin-theme use-package evil company)))
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
;; custom-set-faces was added by Custom.
|
;; custom-set-faces was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@
|
||||||
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
||||||
|
|
||||||
;; Load each modules
|
;; Load each modules
|
||||||
|
(require 'init-package) ; package manager should be loaded first
|
||||||
(require 'init-basic)
|
(require 'init-basic)
|
||||||
(require 'init-keymaps)
|
(require 'init-keymaps)
|
||||||
(require 'init-package)
|
|
||||||
(require 'init-evil)
|
(require 'init-evil)
|
||||||
|
;; (require 'init-lsp) ; FIXME: See .emacs.d/lisp/init-lsp.el
|
||||||
|
|
||||||
;; Load `custom` file
|
;; Load `custom` file
|
||||||
(when (file-exists-p custom-file)
|
(when (file-exists-p custom-file)
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,27 @@
|
||||||
;; Vim-like relativenumber
|
;; Vim-like relativenumber
|
||||||
(setq display-line-numbers-type 'relative)
|
(setq display-line-numbers-type 'relative)
|
||||||
|
|
||||||
|
;; Auto input pairred brackets
|
||||||
|
(electric-pair-mode 1)
|
||||||
|
|
||||||
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs
|
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs
|
||||||
(server-mode 1)
|
(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)
|
||||||
|
|
||||||
|
;; Disable toobar and scrollbar
|
||||||
|
(tool-bar-mode -1)
|
||||||
|
(scroll-bar-mode -1)
|
||||||
|
|
||||||
|
|
||||||
;; Export module
|
;; Export module
|
||||||
(provide 'init-basic)
|
(provide 'init-basic)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,22 @@
|
||||||
"J" 'evil-forward-WORD-end
|
"J" 'evil-forward-WORD-end
|
||||||
"N" '(lambda () (interactive) (evil-next-line 5)) ; 5n
|
"N" '(lambda () (interactive) (evil-next-line 5)) ; 5n
|
||||||
"E" '(lambda () (interactive) (evil-previous-line 5)) ; 5e
|
"E" '(lambda () (interactive) (evil-previous-line 5)) ; 5e
|
||||||
))
|
))
|
||||||
|
|
||||||
|
;; Provides Vim-like Leader key <SPC>
|
||||||
|
(use-package evil-leader
|
||||||
|
:after evil
|
||||||
|
:config
|
||||||
|
(global-evil-leader-mode)
|
||||||
|
(evil-leader/set-leader "<SPC>")
|
||||||
|
(evil-leader/set-key
|
||||||
|
"b" 'buffer-menu))
|
||||||
|
|
||||||
|
;; Evil Commentary: Use gc<action> to toggle comments
|
||||||
|
(use-package evil-commentary
|
||||||
|
:after evil
|
||||||
|
:config
|
||||||
|
(evil-commentary-mode))
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-evil)
|
(provide 'init-evil)
|
||||||
|
|
|
||||||
13
tools/emacs.d/lisp/init-lsp.el
Normal file
13
tools/emacs.d/lisp/init-lsp.el
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
;;; init-lsp.el
|
||||||
|
;;; First edit on 2025/01/29
|
||||||
|
;;; Stores Language Server Protocol Configs
|
||||||
|
;;; FIXME: Cannot install `lsp-mode` plugin, this file will not be loaded by Emacs for now
|
||||||
|
|
||||||
|
(use-package lsp-mode
|
||||||
|
:commands (lsp lsp-deferred)
|
||||||
|
:hook (prog-mode . lsp-deferred))
|
||||||
|
|
||||||
|
|
||||||
|
;; (setq package-check-signature t)
|
||||||
|
(provide 'init-lsp)
|
||||||
|
;;; init-lsp.el ends
|
||||||
|
|
@ -1,24 +1,78 @@
|
||||||
;;; init-package.el
|
;;; init-package.el
|
||||||
|
|
||||||
|
;; Initialise the package sources
|
||||||
|
(require 'package)
|
||||||
|
; Add sources
|
||||||
|
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
|
||||||
|
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||||
|
("org" . "https://orgmode.org/elpa/")
|
||||||
|
("gnu" . "https://elpa.gnu.org/packages/")))
|
||||||
|
;; Initialise the package management system
|
||||||
|
(package-initialize)
|
||||||
|
|
||||||
|
;; Ensure the package list is up-to-date
|
||||||
|
(unless package-archive-contents
|
||||||
|
(package-refresh-contents))
|
||||||
|
|
||||||
;; Ensure use-package is installed
|
;; Ensure use-package is installed
|
||||||
(unless (package-installed-p 'use-package) ; 修正条件检查
|
(unless (package-installed-p 'use-package)
|
||||||
(package-refresh-contents)
|
; (package-refresh-contents) Move to above
|
||||||
(package-install 'use-package))
|
(package-install 'use-package))
|
||||||
|
|
||||||
;; Use `use-package` for plugin management
|
;; Use `use-package` for plugin management
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'use-package))
|
(require 'use-package))
|
||||||
|
(setq use-package-always-ensure t)
|
||||||
|
|
||||||
|
;; This part initialse the GPG Keyring
|
||||||
|
; Disable signature first
|
||||||
|
(setq package-check-signature nil)
|
||||||
|
|
||||||
|
(use-package gnu-elpa-keyring-update)
|
||||||
|
|
||||||
|
; Re-enable signature
|
||||||
|
(setq package-check-signature 'allow-unsigned)
|
||||||
|
|
||||||
;; Company - Complete Anything
|
;; Company - Complete Anything
|
||||||
(use-package company
|
(use-package company
|
||||||
:ensure t
|
:ensure t
|
||||||
:hook (after-init . global-company-mode) ; 在启动后自动启用 global-company-mode
|
:hook (after-init . global-company-mode) ; 在启动后自动启用 global-company-mode
|
||||||
:bind (:map company-active-map ; 自定义快捷键
|
:bind (:map company-active-map ; TODO: Seems does not work
|
||||||
("C-n" . company-select-next)
|
("C-n" . company-select-next)
|
||||||
("C-p" . company-select-previous))
|
("C-p" . company-select-previous))
|
||||||
:config
|
:config
|
||||||
(setq company-minimum-prefix-length 1 ; 设置最短补全前缀
|
(setq company-minimum-prefix-length 1 ; 设置最短补全前缀
|
||||||
company-idle-delay 0.2)) ; 设置补全延迟(秒)
|
company-idle-delay 0.2)) ; 设置补全延迟(秒)
|
||||||
|
|
||||||
|
;; Which Key - Prompt available commands
|
||||||
|
(use-package which-key
|
||||||
|
:ensure t
|
||||||
|
:init
|
||||||
|
(which-key-mode)
|
||||||
|
:config
|
||||||
|
(setq which-key-idle-delay 0.3))
|
||||||
|
|
||||||
|
;; Dashboard
|
||||||
|
(use-package dashboard
|
||||||
|
; Open with :dashboard-open<CR>
|
||||||
|
:after evil
|
||||||
|
:config
|
||||||
|
(dashboard-setup-startup-hook)
|
||||||
|
; Use Emacs mode to use number to navigate dashboard
|
||||||
|
(evil-set-initial-state 'dashboard-mode 'emacs)
|
||||||
|
)
|
||||||
|
;(use-package dashboard
|
||||||
|
; :ensure t
|
||||||
|
; :init
|
||||||
|
; (dashboard-setup-startup-hook)
|
||||||
|
; :config
|
||||||
|
; (setq dashboard-banner-logo-title "EMACS")
|
||||||
|
; (setq dashboard-startup-banner 'official)
|
||||||
|
; (setq dashboard-center-content t)
|
||||||
|
; (setq dashboard-items '((recents . 5)
|
||||||
|
; (bookmark . 5))))
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-package)
|
(provide 'init-package)
|
||||||
;;; init-package.el ends here
|
;;; init-package.el ends here
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ return {
|
||||||
dashboard.button("p", " 查找项目", ":Telescope projects<CR>"),
|
dashboard.button("p", " 查找项目", ":Telescope projects<CR>"),
|
||||||
dashboard.button("h", " 历史文件", ":Telescope oldfiles<CR>"),
|
dashboard.button("h", " 历史文件", ":Telescope oldfiles<CR>"),
|
||||||
dashboard.button("l", " 加载会话", ":SessionSearch<CR>"),
|
dashboard.button("l", " 加载会话", ":SessionSearch<CR>"),
|
||||||
|
-- FIXME: This does not work on Windows - Make it more portable
|
||||||
dashboard.button("c", " 转到设置", ":Telescope find_files cwd=~/.config/nvim<CR>"),
|
dashboard.button("c", " 转到设置", ":Telescope find_files cwd=~/.config/nvim<CR>"),
|
||||||
dashboard.button("SPC q", " 退出", ":qa<CR>"),
|
dashboard.button("SPC q", " 退出", ":qa<CR>"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue