keybindings

This commit is contained in:
janis 2026-07-28 02:04:25 +02:00
parent b8cdd17444
commit 3f86a307a9
Signed by: janis
SSH key fingerprint: SHA256:bB1qbbqmDXZNT0KKD5c2Dfjg53JGhj7B3CFcLIzSqq8

191
init.org
View file

@ -473,7 +473,10 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
#+end_src
* Packages
** =general.el=
** =general.el =
TODO: figure out how to get which-key to correctly display the m label
#+begin_src emacs-lisp
(defconst nemo/leader-evil "SPC")
(defconst nemo/leader-global "C-c")
@ -484,55 +487,70 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe
(use-package general
:straight t
:init
(define-prefix-command 'nemo/xref-command 'nemo/xref-map "xref")
(define-prefix-command 'nemo/buffers-command 'nemo/buffers-map "Buffers..")
(define-prefix-command 'nemo/windows-command 'nemo/windows-map "Windows..")
(define-prefix-command 'nemo/files-command 'nemo/files-map "Files..")
: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)
;; `leader-def` binds with prefix "SPC" into `nemo/leader-prefix-map`
(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-command 'nemo/leader-prefix-command
:prefix-map 'nemo/leader-prefix-map
:global-prefix nemo/leader-global
:prefix nemo/leader-evil
)
:keymaps 'nemo/leader-prefix-map)
(general-create-definer leader-major-def
:states '(emacs normal)
:global-prefix nemo/leader-global
:prefix nemo/leader-evil
)
:global-prefix nemo/leader-global)
;; 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)
(general-def '(emacs normal) 'with-editor-mode-map ",k" 'with-editor-cancel)
(general-def '(emacs normal) :keymaps 'with-editor-mode-map
",," 'with-editor-finish
",k" 'with-editor-cancel)
(leader-def
"<TAB>" #'nemo/switch-to-last-buffer
"<SPC>" #'completion-at-point
"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" '("Edit init.org" . nemo/edit-init-org)
"fs" '("Save" . save-buffer)
"fr" '("rg" . consult-ripgrep)
"fR" '("rg in dir" . nemo/consult-ripgrep-dir)
)
"<TAB>" '("Switch to last buffer" . nemo/switch-to-last-buffer)
"<SPC>" '("Completion at point" . completion-at-point)
"d" '("Duplicate line" . duplicate-line)
"g" '("xref" . nemo/xref-command)
"b" '("Buffers" . nemo/buffers-command)
"w" '("Windows" . nemo/windows-command)
"f" '("Files" . nemo/files-command))
(general-def
:keymaps 'nemo/xref-map
"b" '("Go back" . xref-go-back)
"f" '("Go forward" . xref-go-forward)
"r" '("Find references" . xref-find-references))
(general-def
:keymaps 'nemo/buffers-map
"k" '("Switch to previous buffer" . switch-to-prev-buffer)
"p" '("Switch to previous buffer" . switch-to-prev-buffer)
"j" '("Switch to next buffer" . switch-to-next-buffer)
"n" '("Switch to next buffer" . switch-to-next-buffer)
"b" '("Consult buffer" . consult-buffer)
"d" '("Kill current buffer" . kill-current-buffer)
"s" '("Scratch buffer" . scratch-buffer))
(general-def
:keymaps 'nemo/windows-map
"d" '("Delete window" . delete-window)
"o" '("Delete other windows" . delete-other-windows))
(general-def
:keymaps 'nemo/files-map
"f" '("Find file" . find-file)
"i" '("Edit init.org" . nemo/edit-init-org)
"s" '("Save" . save-buffer)
"r" '("Ripgrep" . consult-ripgrep)
"R" '("Ripgrep in dir" . nemo/consult-ripgrep-dir))
)
#+end_src
** =dired=
@ -601,9 +619,15 @@ Todo: figure out how best to use =image-dired=.
("<tab>" . dired-subtree-toggle)
("TAB" . dired-subtree-toggle)
("C-TAB" . dired-subtree-remove))
:init
(define-prefix-command 'nemo/dired-map)
(leader-major-def :keymaps 'dired-mode-map
"m" '("Dired" . nemo/dired-map))
:config
(leader-def
"p" 'dired-preview-mode)
(general-def
:keymaps 'nemo/dired-map
"p" '("Preview Files" . dired-preview-mode))
(setopt dired-compress-directory-default-suffix ".tar.zst"
dired-create-destination-dirs 'always
dired-filename-display-length 'window
@ -803,12 +827,12 @@ 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
(leader-def
"wj" 'evil-window-down
"wk" 'evil-window-up
"wh" 'evil-window-left
"wl" 'evil-window-right
)
(general-def
:keymaps 'nemo/windows-map
"j" '("Move Down" . evil-window-down)
"k" '("Move Up" . evil-window-up)
"h" '("Move Left" . evil-window-left)
"l" '("Move Right" . evil-window-right))
#+end_src
Advice =evil-search-forward= (bound to =/=) to push the current marker onto the xref stack to allow for returning to where I started searching from:
@ -969,18 +993,27 @@ PDF tools for latex previewing:
:straight t
:defer t
:mode ("\\.pdf\\'" . pdf-view-mode)
:init
(define-prefix-command 'nemo/pdf-map)
:config
(leader-major-def
:keymaps 'pdf-view-mode-map
"g" '("Navigate" . nemo/pdf-map))
(general-def
:keymaps 'nemo/pdf-map
"b" '("Back" . pdf-history-backward)
"f" '("Forward" . pdf-history-forward))
(general-def
:modes '(normal emacs)
:keymaps 'pdf-view-mode-map
"j" `("Scroll Up" . ,(lambda() (interactive) (pdf-view-scroll-up-or-next-page 20)))
"k" `("Scroll Down" . ,(lambda() (interactive) (pdf-view-scroll-down-or-previous-page 20))))
(pdf-loader-install)
(setq-default pdf-view-display-size 'fit-height)
(setq pdf-view-continuous t)
(setq +latex-viewers '(pdf-tools))
(leader-major-def
:keymaps 'pdf-view-mode-map
"g b" #'pdf-history-backward
"g f" #'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
@ -1620,24 +1653,30 @@ Use =inheritenv= and =envrc= to load ~.envrc~ direnv files:
(use-package copilot-chat
:straight (:host github :repo "chep/copilot-chat.el" :files ("*.el"))
:after (org markdown-mode)
:general
:init
(define-prefix-command 'nemo/copilot-map)
:general-config
(leader-def
"cg" '("Generate commit message" . copilot-chat-insert-commit-message)
"cG" '("Regenerate commit message" . copilot-chat-regenerate-commit-message)
"cC" '("Open Copilot Chat" . copilot-chat-display)
"cba" '("Add Buffer to Copilot" . copilot-chat-add-current-buffer)
"cbd" '("Remove Buffer from Copilot" . copilot-chat-del-current-buffer)
"cbw" '("Add Workspace to Copilot" . copilot-chat-add-workspace)
"cbf" #'copilot-chat-add-file
"cbb" '("List Buffers visible to Copilot" . copilot-chat-list)
"cch" #'copilot-chat-hide
"ccx" #'copilot-chat-reset
"ccb" #'copilot-chat-switch-to-buffer
"ccd" #'copilot-chat-doc
"ccr" #'copilot-chat-review
"ccm" #'copilot-chat-set-model
"cy" '("Past latest code block" . copilot-chat-yank)
)
"c" '("Copilot" . nemo/copilot-map))
(general-def
:keymaps 'nemo/copilot-map
"g" '("Generate commit message" . copilot-chat-insert-commit-message)
"G" '("Regenerate commit message" . copilot-chat-regenerate-commit-message)
"C" '("Open Copilot Chat" . copilot-chat-display)
"b" '(:ignore t :wk "Copilot (Chat) Buffers")
"ba" '("Add Buffer to Copilot Chat" . copilot-chat-add-current-buffer)
"bd" '("Remove Buffer from Copilot Chat" . copilot-chat-del-current-buffer)
"bw" '("Add Workspace to Copilot Chat" . copilot-chat-add-workspace)
"bf" '("Add File to Copilot Chat" . copilot-chat-add-file)
"bb" '("List Buffers visible to Copilot Chat" . copilot-chat-list)
"c" '("Copilot Chat" . nil)
"ch" '("Hide Copilot Chat" . copilot-chat-hide)
"cx" '("Reset Copilot Chat" . copilot-chat-reset)
"cb" '("Switch to Copilot Chat buffer" . copilot-chat-switch-to)
"cd" '("Open Copilot Chat doc" . copilot-chat-doc)
"cr" '("Open Copilot Chat review" . copilot-chat-review)
"cm" '("Set Copilot Chat model" . copilot-chat-set-model)
"y" '("Paste latest code block" . copilot-chat-yank))
)
#+end_src
@ -1796,6 +1835,8 @@ Use =eglot= as an alternative to =lsp-mode=:
(use-package eglot
:straight t
:hook ((rust-mode nix-mode prog-mode) . eglot-ensure)
:init
(define-prefix-command 'nemo/eglot-map)
:config
(add-to-list
'eglot-server-programs
@ -1829,8 +1870,8 @@ Use =eglot= as an alternative to =lsp-mode=:
(setq completion-category-defaults nil))
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
:general-config
(general-define-key
:prefix-map 'nemo/eglot-command-map
(general-def
:keymaps 'nemo/eglot-map
"r r" '("Rename" . eglot-rename)
"a a" '("Code Action" . eglot-code-action-quickfix)
"a A" '("Code Action (all)" . eglot-code-actions)
@ -1847,7 +1888,7 @@ Use =eglot= as an alternative to =lsp-mode=:
)
(leader-major-def
:keymaps 'eglot-mode-map
"l" '(:keymap nemo/eglot-command-map :wk "Eglot")
"l" '("Eglot" . nemo/eglot-map)
)
)
@ -2367,14 +2408,15 @@ delimiters < and >'s."
:after (inheritenv envrc)
;; :after (rust-mode)
:hook(rustic-mode . nemo/lsp-format-on-save-mode)
:init
(define-prefix-command 'nemo/rust-map)
:general-config
(general-define-key
:prefix-map 'nemo/rust-map
(general-def
:keymaps 'nemo/rust-map
"c" '("Cargo" . nil)
"c v" '("Check" . rustic-cargo-check)
"c c" '("Compile" . rustic-compile)
"c b" '("Build" . rustic-cargo-build)
;;"c B" '("Build" . rust-cargo-relea)
"c c" '("Clean" . rustic-cargo-clean)
"c x" '("Run" . rustic-cargo-run)
"c f" '("Format Buffer" . rustic-format-buffer)
@ -2390,8 +2432,7 @@ delimiters < and >'s."
)
(leader-major-def
:keymaps 'rustic-mode-map
"m" '(:keymap nemo/rust-map :wk "Cargo")
)
"m" '("Rust" . nemo/rust-map))
:config
(setq rust-mode-treesitter-derive t
rustic-format-on-save nil