From aae8a258f13d5b42d59f97d2934b41ba0348e123 Mon Sep 17 00:00:00 2001 From: Janis Date: Sat, 21 Dec 2024 17:30:15 +0100 Subject: [PATCH] 21.12.24 more keybinding stuff rustic-mode auto-switch to with-help-window windows evil-search-forward pushes marker onto xref stack removed dap-mode cpptools to prevent continuous downloading of some vscode extension --- init.org | 110 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 34 deletions(-) diff --git a/init.org b/init.org index 49b3706..36ae6c5 100644 --- a/init.org +++ b/init.org @@ -300,6 +300,11 @@ Helper function for switching themes. (load-theme nemo/dark-theme t)) #+end_src +** emacs-related +#+begin_src emacs-lisp +(setq help-window-select t + help-window-keep-selected t) +#+end_src ** Fonts Font size [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attributes.html][(height)]] in emacs works in $\frac{1}{10}$ths of points, so ~110~ is the same as ~11~ points. #+begin_src emacs-lisp @@ -460,6 +465,8 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe :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 ) @@ -487,6 +494,7 @@ Honestly not very happy with this at the moment, but it's kind of hacked togethe "wo" #'delete-other-windows "ff" #'find-file "fi" #'nemo/edit-init-org + "fs" #'save-buffer ) ) #+end_src @@ -606,6 +614,18 @@ Evil key-binds, documentation for how this works is [[https://evil.readthedocs.i ) #+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: +#+begin_src emacs-lisp +(defun nemo/evil-search-forward--push-xref + (&optional _regex-p _no-recursive-edit) + "push current marker to xref stack when forward searching." + (xref-push-marker-stack)) + +(advice-add #'evil-search-forward + :before #'nemo/evil-search-forward--push-xref + '((name . "evil-search-push-xref"))) +#+end_src + Close =:config=. #+begin_src emacs-lisp ) @@ -623,7 +643,7 @@ Close =:config=. (use-package evil-collection :after evil :straight t - :init (setq evil-collection-key-blacklist '("C-c ")) + :init (setq evil-collection-key-blacklist '("C-c " "")) :config (evil-collection-init)) #+end_src @@ -744,10 +764,10 @@ PDF tools for latex previewing: (setq-default pdf-view-display-size 'fit-height) (setq pdf-view-continuous t) (setq +latex-viewers '(pdf-tools)) - (leader-other-def + (leader-major-def :keymaps 'pdf-view-mode-map - "gb" 'pdf-history-backward - "gf" 'pdf-history-forward) + "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))) @@ -767,11 +787,12 @@ Taken from [[https://sophiebos.io/posts/prettifying-emacs-org-mode/][ here]]. :general-config (general-define-key :prefix-map 'nemo/org-map + "i" '(:ignore t :which-key "Insert..") "ih" '("Heading" . org-insert-heading) "is" '("Subheading" . org-insert-subheading) "ii" '("Item" . org-insert-item) "ib" '("Block..". org-insert-structure-template) - "il" '("Link" . org-insert-link) + "il" '("Link" . org-insert-link) ) (leader-major-def :keymaps 'org-mode-map @@ -994,9 +1015,8 @@ Use the =move-text= package to move the current line or selection up or down wit #+begin_src emacs-lisp (use-package treemacs :straight t - :defer t ;; hijack projectile prefix because they fit together - :general-config + :general (general-define-key :prefix-map 'project-prefix-map "t" '("Treemacs" . treemacs-select-window) @@ -1349,6 +1369,10 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u :init (setq lsp-keymap-prefix "C-l") :commands lsp + :general-config + (leader-def + "l" '(:keymap lsp-command-map :wk "LSP") + ) :config (setq lsp-idle-delay 0.6 @@ -1409,31 +1433,51 @@ hlsl-mode: ) #+end_src ** Rust -[[https://github.com/rust-lang/rust-mode][rust-mode]] +[[https://github.com/rust-lang/rust-mode][=rust-mode=]] #+begin_src emacs-lisp (use-package rust-mode :straight t - :defer t - :hook (rust-mode . lsp) + :hook (rust-mode . lsp-mode) :init - (setq rust-mode-treesitter-derive t) + (setq rust-mode-treesitter-derive t + )) +#+end_src + +[[https://github.com/brotzeit/rustic][=rustic-mode=]] +#+begin_src emacs-lisp +(use-package rustic + :straight t + :defer t + :after (rust-mode) :general-config (general-define-key :prefix-map 'nemo/rust-map - "c v" '("Check" . rust-check) - "c f" #'rust-format-buffer - "c b" #'rust-compile - "c B" #'rust-compile-release - "c t" #'rust-test - "c r" #'rust-run - "c l" #'rust-run-clippy + "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) + "t t" '("Current Test" . rustic-cargo-current-test) + "t a" '("Test" . rustic-cargo-test) + "c a" '("cargo-add" . rustic-cargo-add) + "c r" '("cargo-rm" . rustic-cargo-remove) + "c l" '("lint" . rustic-cargo-clippy) + "c L" '("lint" . rustic-cargo-clippy-fix) + "c n" '("new" . rustic-cargo-new) + "c i" '("init" . rustic-cargo-init) + "c d" '("Docs" . rustic-cargo-doc) ) (leader-major-def - :keymaps 'rust-mode-map + :keymaps 'rustic-mode-map "m" '(:keymap nemo/rust-map :wk "Cargo") ) + :custom + (rustic-analyzer-command '("/usr/bin/rust-analyzer")) :config - (setq rust-format-on-save t)) + (setq rustic-format-trigger 'on-save) + ) #+end_src #+begin_src emacs-lisp @@ -1442,25 +1486,23 @@ hlsl-mode: :defer t) #+end_src -[[https://github.com/kwrooijen/cargo.el][cargo-mode]] -#+begin_src emacs-lisp -(use-package cargo-mode - :straight t - :defer t - :hook (rust-mode . cargo-minor-mode) - :config - (setq cargo-mode-command-test "test -- --nocapture")) -#+end_src - ** Debugging #+begin_src emacs-lisp (use-package dap-mode :straight t - :defer t + :after (lsp-mode) :config - (require 'dap-cpptools) - (dap-cpptools-setup) - (dap-auto-configure-mode 1)) + ;; (require 'dap-cpptools) + ;; (dap-cpptools-setup) + (require 'dap-gdb-lldb) + (dap-register-debug-template "Rust::GDB Run Configuration" + (list :type "gdb" + :request "launch" + :name "GDB::Run" + :gdbpath "rust-gdb" + :target nil + :cwd nil)) + (dap-auto-configure-mode)) #+end_src ** Web