using general.el for leader keybinds
This commit is contained in:
parent
cb482bebce
commit
6af86b7c54
139
init.org
139
init.org
|
@ -437,6 +437,52 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Packages
|
* Packages
|
||||||
|
** =general.el=
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defconst nemo/leader-evil "SPC")
|
||||||
|
(defconst nemo/leader-global "C-c")
|
||||||
|
|
||||||
|
(use-package general
|
||||||
|
:straight t
|
||||||
|
:config
|
||||||
|
(general-define-key
|
||||||
|
:states '(emacs normal)
|
||||||
|
:prefix-map 'nemo/leader-prefix-map
|
||||||
|
:prefix-command 'nemo/leader-prefix-command
|
||||||
|
:global-prefix nemo/leader-global
|
||||||
|
:prefix nemo/leader-evil)
|
||||||
|
(general-create-definer leader-def
|
||||||
|
:prefix-command 'nemo/leader-prefix-command
|
||||||
|
:prefix-map 'nemo/leader-prefix-map)
|
||||||
|
(general-create-definer leader-other-def
|
||||||
|
:states '(emacs normal)
|
||||||
|
:prefix-map 'nemo/leader-prefix-map
|
||||||
|
:prefix-command 'nemo/leader-prefix-command
|
||||||
|
:global-prefix nemo/leader-global
|
||||||
|
:prefix nemo/leader-evil
|
||||||
|
)
|
||||||
|
;; magit uses with-editor-mode to spawn the git process
|
||||||
|
;; in with the emacs client as the $EDITOR
|
||||||
|
(general-def '(emacs normal) 'with-editor-mode-map ",," 'with-editor-finish)
|
||||||
|
(leader-def
|
||||||
|
"<TAB>" #'nemo/switch-to-last-buffer
|
||||||
|
"d" #'duplicate-line
|
||||||
|
"gb" #'xref-go-back
|
||||||
|
"gf" #'xref-go-forward
|
||||||
|
"bk" #'switch-to-prev-buffer
|
||||||
|
"bp" #'switch-to-prev-buffer
|
||||||
|
"bj" #'switch-to-next-buffer
|
||||||
|
"bn" #'switch-to-next-buffer
|
||||||
|
"bb" #'consult-buffer
|
||||||
|
"bd" #'kill-current-buffer
|
||||||
|
"bs" #'scratch-buffer
|
||||||
|
"wd" #'delete-window
|
||||||
|
"wo" #'delete-other-windows
|
||||||
|
"ff" #'find-file
|
||||||
|
"fi" #'nemo/edit-init-org
|
||||||
|
)
|
||||||
|
)
|
||||||
|
#+end_src
|
||||||
** Web Search
|
** Web Search
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package engine-mode
|
(use-package engine-mode
|
||||||
|
@ -471,7 +517,6 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** =magit=
|
** =magit=
|
||||||
|
|
||||||
try out =diff-hl= for highlighting diffs in magit:
|
try out =diff-hl= for highlighting diffs in magit:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package diff-hl
|
(use-package diff-hl
|
||||||
|
@ -485,6 +530,11 @@ try out =diff-hl= for highlighting diffs in magit:
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:straight t
|
:straight t
|
||||||
:defer t
|
:defer t
|
||||||
|
:general
|
||||||
|
(leader-def
|
||||||
|
"gSh" 'magit-status-here
|
||||||
|
"gs" #'magit-status
|
||||||
|
"gSb" 'magit-blame)
|
||||||
:config
|
:config
|
||||||
(setq magit-mode-quit-window 'magit-restore-window-configuration
|
(setq magit-mode-quit-window 'magit-restore-window-configuration
|
||||||
;;magit-auto-revert-mode t
|
;;magit-auto-revert-mode t
|
||||||
|
@ -541,50 +591,34 @@ Used by Spacemacs as well.
|
||||||
|
|
||||||
Evil key-binds, documentation for how this works is [[https://evil.readthedocs.io/en/latest/keymaps.html][here]]:
|
Evil key-binds, documentation for how this works is [[https://evil.readthedocs.io/en/latest/keymaps.html][here]]:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>TAB") 'mode-line-other-buffer)
|
(leader-def
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>bb") 'consult-buffer)
|
"wj" 'evil-window-down
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>bd") 'kill-current-buffer)
|
"wk" 'evil-window-up
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>ff") 'find-file)
|
"wh" 'evil-window-left
|
||||||
|
"wl" 'evil-window-right
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>fi") 'nemo/edit-init-org)
|
)
|
||||||
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>wj") 'evil-window-down)
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>wk") 'evil-window-up)
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>wh") 'evil-window-left)
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>wl") 'evil-window-right)
|
|
||||||
|
|
||||||
(evil-define-key '(normal visual) 'global (kbd "C-c d") 'duplicate-line)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
I want to bind =SPC g s= to magit status, just how it is in spacemacs.
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>gs") 'magit-status)
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>gB") 'magit-blame)
|
|
||||||
;; (evil-define-key 'normal 'global (kbd "<SPC>gd") 'magit-diff)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
These bindings are somewhat different from spacemacs, which parents the insertion key binds under the major-mode prefix =m=.
|
These bindings are somewhat different from spacemacs, which parents the insertion key binds under the major-mode prefix =m=.
|
||||||
With =TAB= I can cycle headings in org, and with =,,= I can exit the special source block editor.
|
With =TAB= I can cycle headings in org, and with =,,= I can exit the special source block editor.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(evil-define-key 'normal org-mode-map
|
(leader-other-def
|
||||||
(kbd "TAB") 'org-cycle
|
:keymaps 'org-mode-map
|
||||||
(kbd "RET") 'org-open-at-point
|
"ih" 'org-insert-heading
|
||||||
(kbd ",,") 'org-edit-src-exit
|
"is" 'org-insert-subheading
|
||||||
(kbd "<SPC>ih") 'org-insert-heading
|
"ii" 'org-insert-item
|
||||||
(kbd "<SPC>is") 'org-insert-subheading
|
"ib" 'org-insert-structure-template
|
||||||
(kbd "<SPC>ii") 'org-insert-item
|
)
|
||||||
(kbd "<SPC>ib") 'org-insert-structure-template)
|
(general-def 'normal 'org-src-mode-map ",," 'org-edit-src-exit)
|
||||||
|
(general-def 'normal
|
||||||
(evil-define-key '(normal visual) 'org-mode-map
|
:keymaps 'org-mode-map
|
||||||
(kbd "<SPC>il") 'org-insert-link)
|
"TAB" 'org-cycle
|
||||||
#+end_src
|
"RET" 'org-open-at-point)
|
||||||
|
(general-def '(normal visual)
|
||||||
Unassociated key-bindings:
|
:prefix nemo/leader-evil
|
||||||
#+begin_src emacs-lisp
|
:non-normal-prefix nemo/leader-global
|
||||||
;; for exiting out of magit’s commit editor with ,, instead of C-c C-c
|
:keymaps 'org-mode-map
|
||||||
(evil-define-key 'normal ’global (kbd ",,") 'with-editor-finish)
|
"il" 'org-insert-link)
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>gb") 'xref-go-back)
|
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>gf") 'xref-go-forward)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Close =:config=.
|
Close =:config=.
|
||||||
|
@ -604,6 +638,7 @@ Close =:config=.
|
||||||
(use-package evil-collection
|
(use-package evil-collection
|
||||||
:after evil
|
:after evil
|
||||||
:straight t
|
:straight t
|
||||||
|
:init (setq evil-collection-key-blacklist '("C-c <tab>"))
|
||||||
:config
|
:config
|
||||||
(evil-collection-init))
|
(evil-collection-init))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
@ -689,7 +724,7 @@ Also use =undo-fu=, which evil can use.
|
||||||
:bind (("M-$" . jinx-correct)
|
:bind (("M-$" . jinx-correct)
|
||||||
("C-M-$" . jinx-languages))
|
("C-M-$" . jinx-languages))
|
||||||
:config
|
:config
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>Ss") 'jinx-correct)
|
(leader-def "Ss" 'jinx-correct)
|
||||||
(setq jinx-languages "en_GB dk_DK de_DE"))
|
(setq jinx-languages "en_GB dk_DK de_DE"))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
@ -718,11 +753,16 @@ PDF tools for latex previewing:
|
||||||
:config
|
:config
|
||||||
(pdf-loader-install)
|
(pdf-loader-install)
|
||||||
(setq-default pdf-view-display-size 'fit-height)
|
(setq-default pdf-view-display-size 'fit-height)
|
||||||
(setq pdf-view-continuous nil)
|
(setq pdf-view-continuous t)
|
||||||
(setq +latex-viewers '(pdf-tools))
|
(setq +latex-viewers '(pdf-tools))
|
||||||
(evil-define-key 'motion 'pdf-view-mode
|
(leader-other-def
|
||||||
"j" 'pdf-view-next-page
|
:keymaps 'pdf-view-mode-map
|
||||||
"k" 'pdf-view-previous-page))
|
"gb" 'pdf-history-backward
|
||||||
|
"gf" 'pdf-history-forward)
|
||||||
|
(general-def :keymaps 'pdf-view-mode-map
|
||||||
|
"j" (lambda() (interactive) (pdf-view-scroll-up-or-next-page 20))
|
||||||
|
"k" (lambda() (interactive) (pdf-view-scroll-down-or-previous-page 20)))
|
||||||
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Org
|
** Org
|
||||||
|
@ -1479,7 +1519,7 @@ Shortcut for opening this file:
|
||||||
|
|
||||||
Dotfiles with =magit=:
|
Dotfiles with =magit=:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defun magit-dotfiles ()
|
(defun nemo/magit-dotfiles ()
|
||||||
"View Dotfiles repository with magit"
|
"View Dotfiles repository with magit"
|
||||||
(interactive)
|
(interactive)
|
||||||
(require 'magit)
|
(require 'magit)
|
||||||
|
@ -1509,7 +1549,12 @@ Open the current file with a =sudo= tramp:
|
||||||
(tramp-file-name-localname vec)))
|
(tramp-file-name-localname vec)))
|
||||||
(concat "/sudo:root@localhost:" (buffer-file-name))))
|
(concat "/sudo:root@localhost:" (buffer-file-name))))
|
||||||
(goto-char position)))
|
(goto-char position)))
|
||||||
(evil-define-key 'normal 'global (kbd "<SPC>fe") 'sudo-edit-current-file)
|
(leader-def "fe" 'sudo-edit-current-file)
|
||||||
|
|
||||||
|
(defun nemo/switch-to-last-buffer ()
|
||||||
|
(interactive)
|
||||||
|
(switch-to-buffer nil)
|
||||||
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Keybinds
|
* Keybinds
|
||||||
|
|
Loading…
Reference in a new issue