Emacs: fix tree-sitter-based evil commands
Alan Pearce alan@alanpearce.eu
Sun, 11 Jun 2023 08:43:40 +0200
1 files changed, 20 insertions(+), 18 deletions(-)
jump to
M user/emacs/init.el → user/emacs/init.el
@@ -455,27 +455,29 @@ (add-hook 'org-agenda-mode-hook #'evil-org-agenda-set-keys)) :ghook ('org-mode-hook #'evil-org-mode) :gfhook #'evil-org-set-key-theme) -(defun etts/start-of-next-function () - (interactive) - (evil-textobj-tree-sitter-goto-textobj "function.outer" nil nil)) -(defun etts/start-of-prev-function () - (interactive) - (evil-textobj-tree-sitter-goto-textobj "function.outer" t nil)) -(defun etts/end-of-next-function () - (interactive) - (evil-textobj-tree-sitter-goto-textobj "function.outer" nil t)) -(defun etts/end-of-prev-function () - (interactive) - (evil-textobj-tree-sitter-goto-textobj "function.outer" t t)) (use-package evil-textobj-tree-sitter :after evil + :defer 5 + :config (progn + (defun etts/start-of-next-function () + (interactive) + (evil-textobj-tree-sitter-goto-textobj "function.outer" nil nil)) + (defun etts/start-of-prev-function () + (interactive) + (evil-textobj-tree-sitter-goto-textobj "function.outer" t nil)) + (defun etts/end-of-next-function () + (interactive) + (evil-textobj-tree-sitter-goto-textobj "function.outer" nil t)) + (defun etts/end-of-prev-function () + (interactive) + (evil-textobj-tree-sitter-goto-textobj "function.outer" t t)) + (general-define-key :keymaps 'evil-outer-text-objects-map + "f" (evil-textobj-tree-sitter-get-textobj "function.outer") + "a" (evil-textobj-tree-sitter-get-textobj ("conditional.outer" "loop.outer"))) + (general-define-key :keymaps 'evil-inner-text-objects-map + "f" (evil-textobj-tree-sitter-get-textobj "function.inner") + "a" (evil-textobj-tree-sitter-get-textobj ("conditional.inner" "loop.inner")))) :general - (:keymaps 'evil-outer-text-objects-map - "f" (evil-textobj-tree-sitter-get-textobj "function.outer") - "a" (evil-textobj-tree-sitter-get-textobj ("conditional.outer" "loop.outer"))) - (:keymaps 'evil-inner-text-objects-map - "f" (evil-textobj-tree-sitter-get-textobj "function.inner") - "a" (evil-textobj-tree-sitter-get-textobj ("conditional.inner" "loop.inner"))) (:states 'normal "]f" #'etts/start-of-next-function "[f" #'etts/start-of-prev-function