Compare commits

...

2 commits

Author SHA1 Message Date
Janis 6af86b7c54 using general.el for leader keybinds 2024-12-18 23:18:02 +01:00
Janis cb482bebce remember key-chord package 2024-12-18 21:10:19 +01:00

152
init.org
View file

@ -24,6 +24,7 @@ These are some packages which I might want to use in the future, or maybe not, b
create svg images to replace tokens based on regexes
- https://github.com/minad/org-modern
maybe for em dashes? does loads more too.
- https://github.com/emacsorphanage/key-chord
look at org-bullets to make a package which turns =--= and =---= into $\textemdash$ and $\textemdash$.
-> https://github.com/jorgenschaefer/typoel perchance?
@ -436,6 +437,52 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
#+end_src
* 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
#+begin_src emacs-lisp
(use-package engine-mode
@ -470,7 +517,6 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
#+end_src
** =magit=
try out =diff-hl= for highlighting diffs in magit:
#+begin_src emacs-lisp
(use-package diff-hl
@ -482,8 +528,13 @@ try out =diff-hl= for highlighting diffs in magit:
=magit= is awesome and the number one reason why I use Emacs!
#+begin_src emacs-lisp
(use-package magit
:straight t
:straight t
:defer t
:general
(leader-def
"gSh" 'magit-status-here
"gs" #'magit-status
"gSb" 'magit-blame)
:config
(setq magit-mode-quit-window 'magit-restore-window-configuration
;;magit-auto-revert-mode t
@ -540,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]]:
#+begin_src emacs-lisp
(evil-define-key 'normal 'global (kbd "<SPC>TAB") 'mode-line-other-buffer)
(evil-define-key 'normal 'global (kbd "<SPC>bb") 'consult-buffer)
(evil-define-key 'normal 'global (kbd "<SPC>bd") 'kill-current-buffer)
(evil-define-key 'normal 'global (kbd "<SPC>ff") 'find-file)
(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)
(leader-def
"wj" 'evil-window-down
"wk" 'evil-window-up
"wh" 'evil-window-left
"wl" 'evil-window-right
)
#+end_src
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.
#+begin_src emacs-lisp
(evil-define-key 'normal org-mode-map
(kbd "TAB") 'org-cycle
(kbd "RET") 'org-open-at-point
(kbd ",,") 'org-edit-src-exit
(kbd "<SPC>ih") 'org-insert-heading
(kbd "<SPC>is") 'org-insert-subheading
(kbd "<SPC>ii") 'org-insert-item
(kbd "<SPC>ib") 'org-insert-structure-template)
(evil-define-key '(normal visual) 'org-mode-map
(kbd "<SPC>il") 'org-insert-link)
#+end_src
Unassociated key-bindings:
#+begin_src emacs-lisp
;; for exiting out of magits commit editor with ,, instead of C-c C-c
(evil-define-key 'normal global (kbd ",,") 'with-editor-finish)
(evil-define-key 'normal 'global (kbd "<SPC>gb") 'xref-go-back)
(evil-define-key 'normal 'global (kbd "<SPC>gf") 'xref-go-forward)
(leader-other-def
:keymaps 'org-mode-map
"ih" 'org-insert-heading
"is" 'org-insert-subheading
"ii" 'org-insert-item
"ib" 'org-insert-structure-template
)
(general-def 'normal 'org-src-mode-map ",," 'org-edit-src-exit)
(general-def 'normal
:keymaps 'org-mode-map
"TAB" 'org-cycle
"RET" 'org-open-at-point)
(general-def '(normal visual)
:prefix nemo/leader-evil
:non-normal-prefix nemo/leader-global
:keymaps 'org-mode-map
"il" 'org-insert-link)
#+end_src
Close =:config=.
@ -600,11 +635,12 @@ Close =:config=.
#+end_src
#+begin_src emacs-lisp
(use-package evil-collection
:after evil
:straight t
:config
(evil-collection-init))
(use-package evil-collection
:after evil
:straight t
:init (setq evil-collection-key-blacklist '("C-c <tab>"))
:config
(evil-collection-init))
#+end_src
** =undo-fu=
@ -688,7 +724,7 @@ Also use =undo-fu=, which evil can use.
:bind (("M-$" . jinx-correct)
("C-M-$" . jinx-languages))
: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"))
#+end_src
@ -717,11 +753,16 @@ PDF tools for latex previewing:
:config
(pdf-loader-install)
(setq-default pdf-view-display-size 'fit-height)
(setq pdf-view-continuous nil)
(setq pdf-view-continuous t)
(setq +latex-viewers '(pdf-tools))
(evil-define-key 'motion 'pdf-view-mode
"j" 'pdf-view-next-page
"k" 'pdf-view-previous-page))
(leader-other-def
:keymaps 'pdf-view-mode-map
"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
** Org
@ -1478,7 +1519,7 @@ Shortcut for opening this file:
Dotfiles with =magit=:
#+begin_src emacs-lisp
(defun magit-dotfiles ()
(defun nemo/magit-dotfiles ()
"View Dotfiles repository with magit"
(interactive)
(require 'magit)
@ -1508,7 +1549,12 @@ Open the current file with a =sudo= tramp:
(tramp-file-name-localname vec)))
(concat "/sudo:root@localhost:" (buffer-file-name))))
(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
* Keybinds