mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(emacs): Basic emacs setup
This commit is contained in:
parent
2346c13564
commit
6edb5d9e90
7 changed files with 134 additions and 0 deletions
17
tools/emacs.d/.gitignore
vendored
Normal file
17
tools/emacs.d/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# 自动生成的目录
|
||||||
|
/auto-save-list/
|
||||||
|
/elpa/
|
||||||
|
/eshell/
|
||||||
|
/server/
|
||||||
|
/url/
|
||||||
|
|
||||||
|
# 临时文件
|
||||||
|
tutorial
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
.#*
|
||||||
|
*.elc
|
||||||
|
|
||||||
|
# 自动保存的文件
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
12
tools/emacs.d/custom.el
Normal file
12
tools/emacs.d/custom.el
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
(custom-set-variables
|
||||||
|
;; custom-set-variables was added by Custom.
|
||||||
|
;; 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.
|
||||||
|
'(package-selected-packages '(use-package evil company)))
|
||||||
|
(custom-set-faces
|
||||||
|
;; custom-set-faces was added by Custom.
|
||||||
|
;; 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.
|
||||||
|
)
|
||||||
31
tools/emacs.d/init.el
Normal file
31
tools/emacs.d/init.el
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
;;; init.el --- Entry point of GNU/Emacs configuration
|
||||||
|
;;; First edit date 2025/01/27
|
||||||
|
|
||||||
|
;;; Organised by such directory structure
|
||||||
|
;;; init.el -- This file, entry point
|
||||||
|
;;; lisp/
|
||||||
|
;;; init-basic.el
|
||||||
|
;;; init-keymaps.el
|
||||||
|
;;; init-package.el
|
||||||
|
;;; init-evil.el
|
||||||
|
;;; custom.el -- Auto Generated
|
||||||
|
|
||||||
|
;; All elisp files under emacs.d/lisp will be loaded
|
||||||
|
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
|
||||||
|
|
||||||
|
;; Store the auto-generated custom config to `custom.el`
|
||||||
|
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
||||||
|
|
||||||
|
;; Load each modules
|
||||||
|
(require 'init-basic)
|
||||||
|
(require 'init-keymaps)
|
||||||
|
(require 'init-package)
|
||||||
|
(require 'init-evil)
|
||||||
|
|
||||||
|
;; Load `custom` file
|
||||||
|
(when (file-exists-p custom-file)
|
||||||
|
(load custom-file))
|
||||||
|
|
||||||
|
|
||||||
|
;;; init.el end
|
||||||
|
|
||||||
15
tools/emacs.d/lisp/init-basic.el
Normal file
15
tools/emacs.d/lisp/init-basic.el
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
;;; init-basic.el
|
||||||
|
|
||||||
|
;; Disable startup message
|
||||||
|
(setq inhibit-startup-message t)
|
||||||
|
|
||||||
|
;; Use line number by default
|
||||||
|
(global-display-line-numbers-mode 1)
|
||||||
|
;; Vim-like relativenumber
|
||||||
|
(setq display-line-numbers-type 'relative)
|
||||||
|
|
||||||
|
;; https://book.emacs-china.org/#orgcfd105e Open with Emacs
|
||||||
|
(server-mode 1)
|
||||||
|
|
||||||
|
;; Export module
|
||||||
|
(provide 'init-basic)
|
||||||
26
tools/emacs.d/lisp/init-evil.el
Normal file
26
tools/emacs.d/lisp/init-evil.el
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
;;; init-evil.el
|
||||||
|
|
||||||
|
;; Evil - Extensible VI Layer
|
||||||
|
(defvar evil-colemak-state-map (make-sparse-keymap))
|
||||||
|
|
||||||
|
(use-package evil
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(evil-mode 1)
|
||||||
|
; Colemak Vim Arrow
|
||||||
|
(evil-define-key '(normal visual operator) 'global
|
||||||
|
"n" 'evil-next-line
|
||||||
|
"e" 'evil-previous-line
|
||||||
|
"i" 'evil-forward-char
|
||||||
|
"l" 'evil-insert
|
||||||
|
"L" 'evil-insert-0-line
|
||||||
|
"k" 'evil-search-next
|
||||||
|
"K" 'evil-search-previous
|
||||||
|
"j" 'evil-forward-word-end
|
||||||
|
"J" 'evil-forward-WORD-end
|
||||||
|
"N" '(lambda () (interactive) (evil-next-line 5)) ; 5n
|
||||||
|
"E" '(lambda () (interactive) (evil-previous-line 5)) ; 5e
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'init-evil)
|
||||||
11
tools/emacs.d/lisp/init-keymaps.el
Normal file
11
tools/emacs.d/lisp/init-keymaps.el
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
;;; init-keymaps.el
|
||||||
|
|
||||||
|
;; Once this is defined, `M-x open-init-file` will open this file
|
||||||
|
(defun open-init-file()
|
||||||
|
(interactive) ;; Mark function as `interactive` that allows user to access by M-x open-init-file RET
|
||||||
|
(find-file "~/.emacs.d/init.el"))
|
||||||
|
(defun reload-init()
|
||||||
|
(interactive)
|
||||||
|
(load-file "~/.emacs.d/init.el"))
|
||||||
|
|
||||||
|
(provide 'init-keymaps)
|
||||||
22
tools/emacs.d/lisp/init-package.el
Normal file
22
tools/emacs.d/lisp/init-package.el
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
;;; init-package.el
|
||||||
|
|
||||||
|
;; Manual Install Packages (plugins): Options > Manage Emacs Packages (Don't use this)
|
||||||
|
|
||||||
|
(global-company-mode 1) ; Enable company
|
||||||
|
|
||||||
|
;; Ensure use-package is installed (use-package: lazy load plugin manager)
|
||||||
|
(unless (package-install 'use-package)
|
||||||
|
(package-refresh-contents)
|
||||||
|
(package-install 'use-package))
|
||||||
|
|
||||||
|
;; Plugins Here
|
||||||
|
;; Company - Complete Anything
|
||||||
|
(use-package company
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(global-company-mode 1)
|
||||||
|
(define-key company-active-map (kbd "C-n") 'company-select-next)
|
||||||
|
(define-key company-active-map (kbd "C-p") 'company-select-previous))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'init-package)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue