docs(tree-sitter): add documentation sections

also add a line to the quote
This commit is contained in:
Jeetaditya Chatterjee 2021-12-24 14:13:34 +00:00
parent 6508579595
commit 1f5618f02b
No known key found for this signature in database
GPG key ID: 09D54CECD2132B91

View file

@ -14,7 +14,10 @@
- [[#text-objects][Text Objects]] - [[#text-objects][Text Objects]]
- [[#configuration][Configuration]] - [[#configuration][Configuration]]
- [[#disable-text-objects-for-certain-modes][Disable text objects for certain modes]] - [[#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]] - [[#troubleshooting][Troubleshooting]]
- [[#error-bad-bounding-indices-0-1][=(error "Bad bounding indices: 0, 1")=]]
* Description * Description
This module adds [[https://tree-sitter.github.io/tree-sitter/][tree-sitter]] support to doom: 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 #+begin_quote
Tree sitter is a parser generator tool and an incremental parsing library. It 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 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 #+end_quote
It includes: It includes:
@ -74,5 +78,33 @@ want it for ruby we would use this snippet
(remove-hook! 'ruby-mode-hook #'+tree-sitter-keys-mode) (remove-hook! 'ruby-mode-hook #'+tree-sitter-keys-mode)
#+end_src #+end_src
* TODO Troubleshooting ** Adding your own text objects
# Common issues and their solution, or places to look for help. 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!]]