diff options
author | Guangxiong Lin <[email protected]> | 2022-07-08 22:12:27 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2022-07-08 22:12:27 +0800 |
commit | 929f203ac89b254b23f64b29b5b4058f7d009bc5 (patch) | |
tree | 6db7bb2dd6f09ac94dffdb40747e52f61a96ad5e | |
parent | e06f5cab66e1ff586e83f6f4f8871501fd4134d3 (diff) | |
download | dotfiles-929f203ac89b254b23f64b29b5b4058f7d009bc5.tar.gz dotfiles-929f203ac89b254b23f64b29b5b4058f7d009bc5.tar.bz2 dotfiles-929f203ac89b254b23f64b29b5b4058f7d009bc5.zip |
Update emacs config
-rw-r--r-- | .emacs.d/init.el | 2 | ||||
-rw-r--r-- | .emacs.d/lisp/init-appearance.el | 1 | ||||
-rw-r--r-- | .emacs.d/lisp/init-avy.el | 22 | ||||
-rw-r--r-- | .emacs.d/lisp/init-company.el | 10 | ||||
-rw-r--r-- | .emacs.d/lisp/init-corfu.el | 10 | ||||
-rw-r--r-- | .emacs.d/lisp/init-godot.el | 11 | ||||
-rw-r--r-- | .emacs.d/lisp/init-misc.el | 20 | ||||
-rw-r--r-- | .emacs.d/lisp/init-org-roam.el | 50 | ||||
-rw-r--r-- | .emacs.d/lisp/init-org.el | 59 |
9 files changed, 109 insertions, 76 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 663bf79..9f87d7c 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -20,6 +20,7 @@ (require 'init-package) (require 'init-utils) (require 'init-evil) +(require 'init-avy) (require 'init-completion) (require 'init-minibuffer) (require 'init-company) @@ -38,6 +39,7 @@ (require 'init-git) (require 'init-terminal) (require 'init-misc) +(require 'init-godot) (require 'init-appearance) (add-hook 'after-init-hook diff --git a/.emacs.d/lisp/init-appearance.el b/.emacs.d/lisp/init-appearance.el index 8a42f6a..ba5fd51 100644 --- a/.emacs.d/lisp/init-appearance.el +++ b/.emacs.d/lisp/init-appearance.el @@ -18,7 +18,6 @@ (gx/set-appearance--mac))) (gx/load-theme)) - (defun gx/load-theme () (when (gx/maybe-require-package 'doom-themes) (load-theme 'doom-one t) diff --git a/.emacs.d/lisp/init-avy.el b/.emacs.d/lisp/init-avy.el new file mode 100644 index 0000000..9f6262c --- /dev/null +++ b/.emacs.d/lisp/init-avy.el @@ -0,0 +1,22 @@ +(setq avy-background t + avy-all-windows t + avy-timeout-seconds 0.3) +(when (gx/maybe-require-package 'avy) + (define-key global-map (kbd "C-:") #'avy-goto-char-timer) + (define-key global-map (kbd "C-'") #'avy-goto-char-2) + (define-key global-map (kbd "C-c C-j") #'avy-resume) + (with-eval-after-load 'evil + (require 'avy) + (evil-define-key 'normal 'global + (kbd "<SPC>j") 'evil-avy-goto-line-below + (kbd "<SPC>k") 'evil-avy-goto-line-above + (kbd "<SPC>w") 'evil-avy-goto-word-0 + (kbd "<SPC>f") 'evil-avy-goto-char) + (evil-define-key 'visual 'global + (kbd "<SPC>j") 'evil-avy-goto-line-below + (kbd "<SPC>k") 'evil-avy-goto-line-above) + (evil-define-key 'operator 'global + (kbd "<SPC>j") 'evil-avy-goto-line-below + (kbd "<SPC>k") 'evil-avy-goto-line-above))) + +(provide 'init-avy) diff --git a/.emacs.d/lisp/init-company.el b/.emacs.d/lisp/init-company.el index 5f5ac5e..06ff700 100644 --- a/.emacs.d/lisp/init-company.el +++ b/.emacs.d/lisp/init-company.el @@ -1,15 +1,17 @@ (when (gx/maybe-require-package 'company) - (autoload #'global-company-mode "company" nil t) + (add-hook 'ledger-mode-hook #'gx/company-mode-in-tui) + (add-hook 'prog-mode-hook #'gx/company-mode-in-tui)) + +(defun gx/company-mode-in-tui () + "Enable company mode in TUI." (when (not (display-graphic-p)) - (add-hook 'after-init-hook #'global-company-mode 'append))) + (company-mode))) (with-eval-after-load 'company (require 'company-tng) (company-tng-configure-default) (gx/diminish '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.01)) company-selection-wrap-around t) diff --git a/.emacs.d/lisp/init-corfu.el b/.emacs.d/lisp/init-corfu.el index 7b5899d..9acf9d7 100644 --- a/.emacs.d/lisp/init-corfu.el +++ b/.emacs.d/lisp/init-corfu.el @@ -1,10 +1,14 @@ ;; -*- lexical-binding: t; -*- (when (gx/maybe-require-package 'corfu) - (autoload 'corfu-mode "corfu") + (add-hook 'gdscript-mode-hook #'gx/enable-corfu-only-in-gui) + (add-hook 'ledger-mode-hook #'gx/enable-corfu-only-in-gui) + (add-hook 'prog-mode-hook #'gx/enable-corfu-only-in-gui)) + +(defun gx/enable-corfu-only-in-gui () + "Enable Corfu Only In GUI mode." (when (display-graphic-p) - (add-hook 'ledger-mode-hook #'corfu-mode) - (add-hook 'prog-mode-hook #'corfu-mode))) + (corfu-mode))) (setq corfu-cycle t corfu-auto t diff --git a/.emacs.d/lisp/init-godot.el b/.emacs.d/lisp/init-godot.el new file mode 100644 index 0000000..ec438ae --- /dev/null +++ b/.emacs.d/lisp/init-godot.el @@ -0,0 +1,11 @@ +(when (gx/maybe-require-package 'gdscript-mode) + (gx/maybe-require-package 'hydra) + (add-to-list 'auto-mode-alist '("\\.tscn\\'" . gdscript-mode)) + (add-to-list 'auto-mode-alist '("\\.gd\\'" . gdscript-mode)) + (when (gx/maybe-require-package 'eglot) + (add-hook 'gdscript-mode-hook #'eglot-ensure))) + +(setq gdscript-use-tab-indents nil + gdscript-indent-offset 4) + +(provide 'init-godot) diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el index 349e237..f952ed3 100644 --- a/.emacs.d/lisp/init-misc.el +++ b/.emacs.d/lisp/init-misc.el @@ -57,24 +57,6 @@ (with-eval-after-load 'hideshow (gx/diminish 'hs-minor-mode)) -(setq avy-background t - avy-all-windows t - avy-timeout-seconds 0.3) -(when (gx/maybe-require-package 'avy) - (with-eval-after-load 'evil - (require 'avy) - (evil-define-key 'normal 'global - (kbd "<SPC>j") 'evil-avy-goto-line-below - (kbd "<SPC>k") 'evil-avy-goto-line-above - (kbd "<SPC>w") 'evil-avy-goto-word-0 - (kbd "<SPC>f") 'evil-avy-goto-char) - (evil-define-key 'visual 'global - (kbd "<SPC>j") 'evil-avy-goto-line-below - (kbd "<SPC>k") 'evil-avy-goto-line-above) - (evil-define-key 'operator 'global - (kbd "<SPC>j") 'evil-avy-goto-line-below - (kbd "<SPC>k") 'evil-avy-goto-line-below))) - (gx/maybe-require-package 'rg) (gx/maybe-require-package 'esup) @@ -114,7 +96,7 @@ (when (gx/maybe-require-package 'edwina) (setq display-buffer-base-action '(display-buffer-below-selected)) - (autoload #'edwina-mode "edwina" nil t) + (setq edwina-mfact 0.5) (add-hook 'after-init-hook #'edwina-mode 'append)) (provide 'init-misc) diff --git a/.emacs.d/lisp/init-org-roam.el b/.emacs.d/lisp/init-org-roam.el new file mode 100644 index 0000000..f460761 --- /dev/null +++ b/.emacs.d/lisp/init-org-roam.el @@ -0,0 +1,50 @@ +;; roam +(when (gx/maybe-require-package 'org-roam) + (add-hook 'org-mode-hook #'org-roam-db-autosync-mode) + (define-key global-map (kbd "C-c n f") #'org-roam-node-find) + (define-key global-map (kbd "C-c n c") #'org-roam-capture) + (define-key global-map (kbd "C-c n j") #'org-roam-dailies-capture-today) + (with-eval-after-load 'org + (define-key org-mode-map (kbd "C-c n i") #'org-roam-node-insert) + (define-key org-mode-map (kbd "C-c n l") #'org-roam-buffer-toggle))) + +(with-eval-after-load 'evil + (evil-define-key 'normal 'global + (kbd "<leader>fn") 'org-roam-node-find + (kbd "<leader>cn") 'org-roam-dailies-goto-today) + (evil-define-key 'normal org-mode-map + (kbd "<leader><SPC>b") 'org-roam-buffer-toggle + (kbd "<leader>in") 'org-roam-node-insert + (kbd "[d") 'org-roam-dailies-goto-previous-note + (kbd "]d") 'org-roam-dailies-goto-next-note)) +(setq org-roam-directory (file-truename "~/words")) +(setq org-roam-db-gc-threshold most-positive-fixnum) +(setq org-roam-dailies-directory "journals/") +(setq org-roam-dailies-capture-templates + '(("d" "daily" entry + "* %?" + :target (file+head "%<%Y/%Y-%m-%d>.org" + "#+title: %<%a %d %b %Y>\n")) + ("w" "weekly" entry + "* %?" + :target (file+head+olp "%<%Y/week%V>.org" + "#+title: Week %<%V %Y>\n" + ("%<%Y-%m-%d %A>"))) + ("m" "monthly" entry + "* %?" + :target (file+head "%<%Y/%Y-%m>.org" + "#+title: %<%B %Y>\n")) + ("y" "yearly" entry + "* %?" + :target (file+head "%<%Y/%Y>.org" + "#+title: %<%Y>\n")))) + +;; roam ui +(when (gx/maybe-require-package 'org-roam-ui) + (define-key global-map (kbd "C-c n g") #'org-roam-ui-open)) +(setq org-roam-ui-follow t + org-roam-ui-sync-theme t + org-roam-ui-update-on-save t + org-roam-ui-open-at-start t) + +(provide 'init-org-roam) diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el index 12ca4f2..15e5d03 100644 --- a/.emacs.d/lisp/init-org.el +++ b/.emacs.d/lisp/init-org.el @@ -105,10 +105,15 @@ ;; capture (setq org-capture-templates - '(("t" "TODO" entry (file+headline org-default-notes-file "Tasks") - "* TODO %?\nCaptured on %U") - ("j" "Journal" entry (file+datetree org-default-notes-file) - "* %?\nCaptured on %U"))) + `(("t" "TODO" entry + (file+headline org-default-notes-file + ,(format-time-string "%Y-%m-%d %A")) + "* TODO %?\nCaptured on %U") + ("j" "Journal" + entry + (file+headline org-default-notes-file + ,(format-time-string "%Y-%m-%d %A")) + "* %?\nCaptured on %U"))) ;; clock (setq org-clock-persist 'history) @@ -128,51 +133,6 @@ '((shell . t) (plantuml . t)))) -;; roam -(when (gx/maybe-require-package 'org-roam) - (autoload #'org-roam-node-find "org-roam-node" nil t) - (autoload #'org-roam-dailies-goto-today "org-roam-dailies" nil t) - (add-hook 'org-mode-hook #'org-roam-db-autosync-mode)) - -(with-eval-after-load 'org - (define-key org-mode-map (kbd "C-c n i") #'org-roam-node-insert)) -(with-eval-after-load 'evil - (evil-define-key 'normal 'global - (kbd "<leader>fn") 'org-roam-node-find - (kbd "<leader>cn") 'org-roam-dailies-goto-today) - (evil-define-key 'normal org-mode-map - (kbd "<leader><SPC>b") 'org-roam-buffer-toggle - (kbd "<leader>in") 'org-roam-node-insert - (kbd "[d") 'org-roam-dailies-goto-previous-note - (kbd "]d") 'org-roam-dailies-goto-next-note)) -(setq org-roam-directory (file-truename "~/words")) -(setq org-roam-db-gc-threshold most-positive-fixnum) -(setq org-roam-dailies-directory "journals/") -(setq org-roam-dailies-capture-templates - '(("d" "daily" entry - "* %?" - :target (file+head "%<%Y/%Y-%m-%d>.org" - "#+title: %<%a %d %b %Y>\n")) - ("w" "weekly" entry - "* %?" - :target (file+head "%<%Y/week%V>.org" - "#+title: Week %<%V %Y>\n")) - ("m" "monthly" entry - "* %?" - :target (file+head "%<%Y/%Y-%m>.org" - "#+title: %<%B %Y>\n")) - ("y" "yearly" entry - "* %?" - :target (file+head "%<%Y/%Y>.org" - "#+title: %<%Y>\n")))) - -;; roam ui -(gx/maybe-require-package 'org-roam-ui) -(setq org-roam-ui-follow t - org-roam-ui-sync-theme t - org-roam-ui-update-on-save t - org-roam-ui-open-at-start t) - ;; alert (when (gx/maybe-require-package 'org-alert) (autoload 'org-alert-enable "org-alert")) @@ -182,5 +142,6 @@ (setq alert-default-style 'osx-notifier)) (setq org-alert-interval 60) +(require 'init-org-roam) (require 'init-org-agenda) (provide 'init-org) |