From eeb5ad48ae9e24d18bd76ec13a823c705c4133ca Mon Sep 17 00:00:00 2001 From: dx Date: Wed, 15 Apr 2020 04:35:36 +0100 Subject: +narrowing keybind to code subleader This keybind will narrow into a singular function when the cursor is on the function line --- doom.d/org/config.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'doom.d/org/config.org') diff --git a/doom.d/org/config.org b/doom.d/org/config.org index f744115..38df731 100644 --- a/doom.d/org/config.org +++ b/doom.d/org/config.org @@ -442,6 +442,24 @@ General keymap for leader :desc "Swap windows" "S" #'ace-swap-window) ; allows me to switch windows more efficiently than before, better than just motions #+END_SRC ** Code +*** Narrow handlers +- Toggles narrow to function by checking a variable +#+BEGIN_SRC elisp +(setq oreodave/narrow/narrow-state 0) +(defun oreodave/narrow/toggle-narrow-state () + (if (= oreodave/narrow/narrow-state 1) + (setq oreodave/narrow/narrow-state 0) + (setq oreodave/narrow/narrow-state 1))) + +(add-hook 'post-command-hook #'oreodave/narrow/toggle-narrow-state) + +(defun oreodave/narrow/toggle-narrow () + (interactive) + (if (= oreodave/narrow/narrow-state 1) + (narrow-to-defun) + (widen))) +#+END_SRC +*** Keybinds - Some keybinds for the code prefix which help me with coding or working with code, particularly LSP #+BEGIN_SRC elisp @@ -450,6 +468,7 @@ General keymap for leader :prefix ("c" . "code") ; Code :desc "Fold all in level" "f" #'hs-hide-level :desc "Compile via make" "C" #'+make/run + :desc "Narrow to function" "n" #'oreodave/narrow/toggle-narrow (:after format-all :desc "Format code" "=" #'format-all-buffer) (:after lsp -- cgit v1.2.3-13-gbd6f