From 65207ab3dc2875c0c7920cf2c3e46c59bf99cdf4 Mon Sep 17 00:00:00 2001 From: Jeetaditya Chatterjee Date: Sun, 10 Apr 2022 18:13:20 +0100 Subject: [PATCH] docs(tree-sitter): add rebinding keys section --- modules/tools/tree-sitter/README.org | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/tools/tree-sitter/README.org b/modules/tools/tree-sitter/README.org index 2c223a7e0..653d843fa 100644 --- a/modules/tools/tree-sitter/README.org +++ b/modules/tools/tree-sitter/README.org @@ -15,6 +15,7 @@ - [[#goto-certain-nodes][Goto certain nodes]] - [[#configuration][Configuration]] - [[#disable-text-objects-for-certain-modes][Disable text objects for certain modes]] + - [[#rebinding-text-objects][Rebinding text objects]] - [[#adding-your-own-text-objects][Adding your own text objects]] - [[#disabling-highlighting-for-certain-modes][Disabling highlighting for certain modes]] - [[#troubleshooting][Troubleshooting]] @@ -85,6 +86,23 @@ want it for ruby we would use this snippet (remove-hook 'ruby-mode-hook #'+tree-sitter-keys-mode) #+end_src +** Rebinding text objects +Rebinding keys is the same as any other key but do notes they need to be bound +to the keymaps ~+tree-sitter-inner-text-object-map~ or +~+tree-sitter-outer-text-object-map~ +#+begin_src emacs-lisp +(map! (:map +tree-sitter-outer-text-objects-map + "f" nil + "f" (evil-textobj-tree-sitter-get-textobj "call.inner") + "F" nil + "F" (evil-textobj-tree-sitter-get-textobj "function.inner")) + (:map +tree-sitter-inner-text-objects-map + "f" nil + "f" (evil-textobj-tree-sitter-get-textobj "call.inner") + "F" nil + "F" (evil-textobj-tree-sitter-get-textobj "function.inner"))) +#+end_src + ** Adding your own text objects If you wish to [[https://github.com/meain/evil-textobj-tree-sitter#custom-textobjects][add your own custom text objects]] then you need to bind them and add them to the ~+tree-sitter-{inner, outer}-text-objects-map~