diff --git a/modules/tools/tree-sitter/README.org b/modules/tools/tree-sitter/README.org index 222215c07..c8c3da033 100644 --- a/modules/tools/tree-sitter/README.org +++ b/modules/tools/tree-sitter/README.org @@ -14,7 +14,10 @@ - [[#text-objects][Text Objects]] - [[#configuration][Configuration]] - [[#disable-text-objects-for-certain-modes][Disable text objects for certain modes]] + - [[#adding-your-own-text-objects][Adding your own text objects]] + - [[#disabling-highlighting-for-certain-modes][Disabling highlighting for certain modes]] - [[#troubleshooting][Troubleshooting]] + - [[#error-bad-bounding-indices-0-1][=(error "Bad bounding indices: 0, 1")=]] * Description This module adds [[https://tree-sitter.github.io/tree-sitter/][tree-sitter]] support to doom: @@ -22,7 +25,8 @@ This module adds [[https://tree-sitter.github.io/tree-sitter/][tree-sitter]] sup #+begin_quote Tree sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the -syntax tree as the source file is edited. +syntax tree as the source file is edited. This allows for features of the editor + to become syntax aware. #+end_quote It includes: @@ -74,5 +78,33 @@ want it for ruby we would use this snippet (remove-hook! 'ruby-mode-hook #'+tree-sitter-keys-mode) #+end_src -* TODO Troubleshooting -# Common issues and their solution, or places to look for help. +** 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~ +for example: +#+begin_src emacs-lisp +(map! (:map +tree-sitter-outer-text-objects-map + "m" (evil-textobj-tree-sitter-get-textobj "import" + '((python-mode . [(import_statement) @import]) + (rust-mode . [(use_declaration) @import]))))) +#+end_src + +** Disabling highlighting for certain modes +If you want to disable highlighting by default you can add a +#+begin_src emacs-lisp +(after! MODE-PACKAGE + (tree-sitter-hl-mode -1)) +#+end_src + +If you only want it for certain modes then +#+begin_src emacs-lisp +(remove-hook! 'tree-sitter-after-on-hook #'tree-sitter-hl-mode) + +(add-hook! 'MAJOR-MODE-HOOK #'tree-sitter-hl-mode) +#+end_src + +* Troubleshooting +** =(error "Bad bounding indices: 0, 1")= +This means that the text object does not have the underlying query needed, this can be +fixed by either adding in a custom query (which would override the current key +bound.) or [[https://github.com/nvim-treesitter/nvim-treesitter-textobjects/][contributing upstream!]]