aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-13 00:07:38 +0800
committerGuangxiong Lin <[email protected]>2022-03-13 00:09:13 +0800
commit38ab771977e6511d02df06cb908824707d728303 (patch)
tree2c77fb392b35e8e7c2105d3bb29f24b34c5388f7 /.emacs.d/lisp
parent0097d1f3e22565ffb6db689c06ee2f9610cd45d0 (diff)
downloaddotfiles-38ab771977e6511d02df06cb908824707d728303.tar.gz
dotfiles-38ab771977e6511d02df06cb908824707d728303.tar.bz2
dotfiles-38ab771977e6511d02df06cb908824707d728303.zip
Refactor emacs config
Use less use-package features
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-company.el10
-rw-r--r--.emacs.d/lisp/init-deft.el15
-rw-r--r--.emacs.d/lisp/init-filetype.el3
-rw-r--r--.emacs.d/lisp/init-git.el9
-rw-r--r--.emacs.d/lisp/init-input-method.el37
-rw-r--r--.emacs.d/lisp/init-ivy.el18
-rw-r--r--.emacs.d/lisp/init-lang.el76
-rw-r--r--.emacs.d/lisp/init-markdown.el13
-rw-r--r--.emacs.d/lisp/init-misc.el136
-rw-r--r--.emacs.d/lisp/init-package.el13
-rw-r--r--.emacs.d/lisp/init-projectile.el13
11 files changed, 148 insertions, 195 deletions
diff --git a/.emacs.d/lisp/init-company.el b/.emacs.d/lisp/init-company.el
new file mode 100644
index 0000000..c096e86
--- /dev/null
+++ b/.emacs.d/lisp/init-company.el
@@ -0,0 +1,10 @@
+(use-package company :ensure t :defer t)
+
+(add-hook 'after-init-hook 'global-company-mode)
+
+(setq company-global-modes
+ '(emacs-lisp-mode go-mode ledger-mode sh-mode c++-mode))
+(setq company-minimum-prefix-length 1
+ company-idle-delay (lambda () (if (company-in-string-or-comment) nil 0.3)))
+
+(provide 'init-company)
diff --git a/.emacs.d/lisp/init-deft.el b/.emacs.d/lisp/init-deft.el
index 352021a..6cc18ea 100644
--- a/.emacs.d/lisp/init-deft.el
+++ b/.emacs.d/lisp/init-deft.el
@@ -1,11 +1,8 @@
-(use-package deft
- :ensure t
- :after (org)
- :config
- (setq deft-recursive t
- deft-use-filter-string-for-filename t
- deft-extensions '("org" "txt" "md" "tex")
- deft-directory org-roam-directory
- deft-use-filename-as-title t))
+(use-package deft :ensure t :defer t)
+(setq deft-recursive t
+ deft-use-filter-string-for-filename t
+ deft-extensions '("org" "txt" "md" "tex")
+ deft-directory org-roam-directory
+ deft-use-filename-as-title t)
(provide 'init-deft)
diff --git a/.emacs.d/lisp/init-filetype.el b/.emacs.d/lisp/init-filetype.el
index 93505a8..e27c119 100644
--- a/.emacs.d/lisp/init-filetype.el
+++ b/.emacs.d/lisp/init-filetype.el
@@ -1,4 +1,3 @@
-(add-to-list 'auto-mode-alist
- '("\\.rkt\\'" . scheme-mode))
+(add-to-list 'auto-mode-alist '("\\.rkt\\'" . scheme-mode))
(provide 'init-filetype)
diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el
new file mode 100644
index 0000000..c903636
--- /dev/null
+++ b/.emacs.d/lisp/init-git.el
@@ -0,0 +1,9 @@
+(use-package magit :ensure t :defer t)
+
+(with-eval-after-load 'evil
+ (evil-define-key 'normal 'global
+ (kbd "<leader>gs") 'magit))
+
+(setq magit-refresh-status-buffer nil)
+
+(provide 'init-git)
diff --git a/.emacs.d/lisp/init-input-method.el b/.emacs.d/lisp/init-input-method.el
index 8c007bc..157c632 100644
--- a/.emacs.d/lisp/init-input-method.el
+++ b/.emacs.d/lisp/init-input-method.el
@@ -1,27 +1,20 @@
(when *is-a-linux*
- (use-package fcitx
- :ensure t
- :init
- (setq fcitx-remote-command "fcitx5-remote")
- :config
- (fcitx-aggressive-setup)))
+ (use-package fcitx :ensure t :defer t)
+ (setq fcitx-remote-command "fcitx5-remote")
+ (fcitx-aggressive-setup))
(when *is-a-mac*
- (use-package sis
- :ensure t
- :after (evil)
- :init
- (setq sis-external-ism "/usr/local/bin/macism")
- (setq sis-english-source "com.apple.keylayout.ABC"
- sis-other-source "com.apple.inputmethod.SCIM.ITABC")
- (setq sis-do-set
- (lambda (source) (start-process "set-input-source" nil
- sis-external-ism source)))
- (setq sis-do-get
- (lambda () (start-process "get-input-source" nil
- sis-external-ism)))
- :config
- (sis-global-respect-mode t)
- (sis-global-context-mode t)))
+ (use-package sis :ensure t :defer t)
+ (setq sis-external-ism "/usr/local/bin/macism")
+ (setq sis-english-source "com.apple.keylayout.ABC"
+ sis-other-source "com.apple.inputmethod.SCIM.ITABC")
+ (setq sis-do-set
+ (lambda (source) (start-process "set-input-source" nil
+ sis-external-ism source)))
+ (setq sis-do-get
+ (lambda () (start-process "get-input-source" nil
+ sis-external-ism)))
+ (sis-global-respect-mode t)
+ (sis-global-context-mode t))
(provide 'init-input-method)
diff --git a/.emacs.d/lisp/init-ivy.el b/.emacs.d/lisp/init-ivy.el
new file mode 100644
index 0000000..b1fb73a
--- /dev/null
+++ b/.emacs.d/lisp/init-ivy.el
@@ -0,0 +1,18 @@
+(use-package counsel :ensure t :defer t)
+
+(add-hook 'after-init-hook (lambda () (ivy-mode 1)))
+
+(with-eval-after-load 'evil
+ (evil-define-key 'normal ivy-mode-map
+ (kbd "<leader>fb") 'ivy-switch-buffer
+ (kbd "<leader>fm") 'counsel-recentf
+ (kbd "<leader>fc") 'counsel-M-x
+ (kbd "<leader>fl") 'swiper))
+
+(setq ivy-use-virtual-buffers t)
+(setq ivy-count-format "(%d/%d) ")
+(setq ivy-re-builders-alist
+ '((read-file-name-internal . ivy--regex-fuzzy)
+ (t . ivy--regex-plus)))
+
+(provide 'init-ivy)
diff --git a/.emacs.d/lisp/init-lang.el b/.emacs.d/lisp/init-lang.el
index f281ac9..341321a 100644
--- a/.emacs.d/lisp/init-lang.el
+++ b/.emacs.d/lisp/init-lang.el
@@ -1,64 +1,28 @@
-(use-package ledger-mode
- :mode (("\\.journal$" . ledger-mode))
- :config
+(use-package ledger-mode :ensure t :defer t)
+(add-to-list 'auto-mode-alist '("\\.journal\\'" . ledger-mode))
+(with-eval-after-load 'ledger-mode
(setq ledger-default-date-format ledger-iso-date-format))
-(use-package markdown-mode
- :ensure t
- :commands (markdown-mode gfm-mode)
- :mode (("README\\.md\\'" . gfm-mode)
- ("\\.md\\'" . markdown-mode)
- ("\\.markdown\\'" . markdown-mode))
- :init
- (setq markdown-command '("pandoc" "--from=markdown" "--to=html5")))
+(use-package go-mode :ensure t :defer t)
+(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
+(add-hook 'go-mode-hook (lambda () (setq tab-width 4)))
-(with-eval-after-load 'evil
- (evil-define-key 'normal markdown-mode-map
- (kbd "<RET>") 'markdown-follow-link-at-point))
+(use-package go-dlv :ensure t :defer t)
-(use-package go-mode
- :ensure t
- :commands (go-mode)
- :mode (("\\.go$" . go-mode))
- :hook ((go-mode . (lambda () (setq tab-width 4)))))
+(use-package eglot :ensure t :defer t)
+(add-hook 'go-mode-hook 'eglot-ensure)
-(use-package go-dlv
- :ensure t
- :after (go-mode))
+(use-package realgud :ensure t :defer t)
-(use-package eglot
- :ensure t
- :commands (eglot)
- :hook
- ((go-mode . eglot-ensure)))
-
-(use-package magit
- :ensure t
- :commands (magit magit-status)
- :init
- (setq magit-refresh-status-buffer nil))
-
-(with-eval-after-load 'evil
- (evil-define-key 'normal 'global
- (kbd "<leader>gs") 'magit))
-
-
-(use-package realgud
- :defer t
- :ensure t)
-
-(use-package plantuml-mode
- :ensure t
- :defer t
- :init
- (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
- :config
- (setq plantuml-jar-path "~/.local/bin/plantuml.jar"
- plantuml-default-exec-mode 'jar
- org-plantuml-jar-path "~/.local/bin/plantuml.jar"
- org-plantuml-default-exec-mode 'jar)
- (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
- (unless (file-readable-p plantuml-jar-path)
- (plantuml-download-jar)))
+(use-package plantuml-mode :ensure t :defer t)
+(add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode))
+(setq plantuml-jar-path "~/.local/bin/plantuml.jar"
+ plantuml-default-exec-mode 'jar
+ org-plantuml-jar-path plantuml-jar-path
+ org-plantuml-default-exec-mode 'jar)
+(unless (file-readable-p plantuml-jar-path)
+ (plantuml-download-jar))
+(with-eval-after-load 'org
+ (add-to-list 'org-src-lang-modes '("plantuml" . plantuml)))
(provide 'init-lang)
diff --git a/.emacs.d/lisp/init-markdown.el b/.emacs.d/lisp/init-markdown.el
new file mode 100644
index 0000000..94c718f
--- /dev/null
+++ b/.emacs.d/lisp/init-markdown.el
@@ -0,0 +1,13 @@
+(use-package markdown-mode :ensure t :defer t)
+
+(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
+(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
+(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
+
+(with-eval-after-load 'evil
+ (evil-define-key 'normal markdown-mode-map
+ (kbd "<RET>") 'markdown-follow-link-at-point))
+
+(setq markdown-command '("pandoc" "--from=markdown" "--to=html5"))
+
+(provide 'init-markdown)
diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el
index 35e9756..56e8a2c 100644
--- a/.emacs.d/lisp/init-misc.el
+++ b/.emacs.d/lisp/init-misc.el
@@ -23,106 +23,46 @@
`((".*" "~/.emacs.d/backups/" t)))
(setq-default fill-column 72)
-(menu-bar-mode -1)
-(xterm-mouse-mode 1) ;; Enable mouse
-(tool-bar-mode -1)
-(toggle-scroll-bar -1)
-(global-auto-revert-mode t)
-(global-so-long-mode 1)
+(setq-default
+ recentf-max-saved-items 1024
+ recentf-exclude `("/tmp/"))
+(setq show-paren-when-point-inside-paren t
+ show-paren-when-point-in-periphery t)
-(add-hook 'after-init-hook #'global-hl-line-mode)
(add-hook 'prog-mode-hook #'hs-minor-mode) ;; allow folding
-
-(fset 'yes-or-no-p 'y-or-n-p)
-
-(use-package paren
- :ensure nil
- :init
- (add-hook 'after-init-hook #'show-paren-mode)
- :config
- (setq show-paren-when-point-inside-paren t
- show-paren-when-point-in-periphery t))
-
-(use-package atom-one-dark-theme
- :ensure t
- :config
- (load-theme 'atom-one-dark t))
-(set-face-attribute 'default nil :height 130)
-
-(use-package which-key
- :ensure t
- :config
- (which-key-mode))
-
-(use-package undo-tree
- :config
- (global-undo-tree-mode))
-
-(use-package recentf
- :ensure nil
- :init
- (add-hook 'after-init-hook 'recentf-mode)
- :config
- (setq-default
- recentf-max-saved-items 1024
- recentf-exclude `("/tmp/")))
-
-(use-package counsel
- :after evil
- :init
- (evil-define-key 'normal ivy-mode-map
- (kbd "<leader>fb") 'ivy-switch-buffer
- (kbd "<leader>fm") 'counsel-recentf
- (kbd "<leader>fc") 'counsel-M-x
- (kbd "<leader>fl") 'swiper)
- (global-set-key (kbd "C-c C-r") 'ivy-resume)
- :config
- (ivy-mode 1)
- (setq ivy-use-virtual-buffers t)
- (setq ivy-count-format "(%d/%d) ")
- (setq ivy-re-builders-alist
- '((read-file-name-internal . ivy--regex-fuzzy)
- (t . ivy--regex-plus))))
-
-(use-package exec-path-from-shell
- :if (memq window-system '(mac ns))
- :ensure t
- :config
- (setq exec-path-from-shell-arguments '("-l"))
+(add-hook 'after-init-hook
+ (lambda ()
+ (global-hl-line-mode)
+ (menu-bar-mode -1)
+ (xterm-mouse-mode 1) ;; Enable mouse
+ (tool-bar-mode -1)
+ (toggle-scroll-bar -1)
+ (global-auto-revert-mode t)
+ (global-so-long-mode 1)
+ (recentf-mode)
+ (show-paren-mode)
+ (fset 'yes-or-no-p 'y-or-n-p)))
+
+(use-package avy :ensure t :defer t)
+(use-package rg :ensure t :defer t)
+(use-package esup :ensure t :defer t)
+
+;; appearance
+(use-package atom-one-dark-theme :ensure t :defer t)
+(add-hook 'after-init-hook
+ (lambda ()
+ (load-theme 'atom-one-dark t)
+ (set-face-attribute 'default nil :height 130)))
+
+(use-package which-key :ensure t :defer t)
+(add-hook 'after-init-hook 'which-key-mode)
+
+(use-package undo-tree :ensure t :defer t)
+(add-hook 'after-init-hook 'global-undo-tree-mode)
+
+(use-package exec-path-from-shell :ensure t :defer t)
+(setq exec-path-from-shell-arguments '("-l"))
+(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
-(use-package avy
- :ensure t)
-
-(use-package company
- :init
- (setq company-global-modes
- '(emacs-lisp-mode go-mode ledger-mode sh-mode c++-mode))
- :hook ((after-init . global-company-mode))
- :config
- (setq company-minimum-prefix-length 1
- company-idle-delay (lambda () (if (company-in-string-or-comment) nil 0.3))))
-
-(use-package projectile
- :init
- (setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)
- projectile-require-project-root nil)
- :config
- (projectile-mode 1))
-
-(with-eval-after-load 'evil
- (evil-define-key 'normal projectile-mode-map
- (kbd "<leader>p") 'projectile-command-map
- (kbd "<leader>ff") 'projectile-find-file
- (kbd "<leader>fr") 'projectile-ripgrep))
-
-(use-package rg
- :ensure t
- :commands (rg rg-menu))
-
-(use-package esup
- :ensure t
- :defer t
- :commands (esup))
-
(provide 'init-misc)
diff --git a/.emacs.d/lisp/init-package.el b/.emacs.d/lisp/init-package.el
index bad2d23..1501de4 100644
--- a/.emacs.d/lisp/init-package.el
+++ b/.emacs.d/lisp/init-package.el
@@ -9,14 +9,11 @@
(package-refresh-contents)
(package-install package)))
(require 'use-package)
-(setq use-package-always-ensure t)
+(setq use-package-always-ensure t
+ use-package-always-defer t)
-(use-package auto-package-update
- :ensure t
- :commands (auto-package-update-now)
- :config
- (setq auto-package-update-delete-old-versions t
- auto-package-update-hide-results t))
-
+(use-package auto-package-update)
+(setq auto-package-update-delete-old-versions t
+ auto-package-update-hide-results t)
(provide 'init-package)
diff --git a/.emacs.d/lisp/init-projectile.el b/.emacs.d/lisp/init-projectile.el
new file mode 100644
index 0000000..6f305b6
--- /dev/null
+++ b/.emacs.d/lisp/init-projectile.el
@@ -0,0 +1,13 @@
+(use-package projectile :ensure t :defer t)
+
+(setq projectile-cache-file (expand-file-name ".cache/projectile" user-emacs-directory)
+ projectile-require-project-root nil)
+(add-hook 'after-init-hook (lambda () (projectile-mode 1)))
+
+(with-eval-after-load 'evil
+ (evil-define-key 'normal projectile-mode-map
+ (kbd "<leader>p") 'projectile-command-map
+ (kbd "<leader>ff") 'projectile-find-file
+ (kbd "<leader>fr") 'projectile-ripgrep))
+
+(provide 'init-projectile)