Henrik already reviewed it, I think there’s one remaining issue regarding lazy loading that needs to be solved before it can be merged.
It can help with indentation, but I’m not sure it comes out of the box in the module, but iirc there’s a package.
It doesn’t conflict with lsp-mode, and imo it’s totally worth it for the better syntax highlighting alone, but it also has other useful features like ast aware text objects and folding. Basically all upsides so far.
There is also this tracking post, but I’m not sure how up to date it is.
Tree sitter is very much a general tool, so anyone can jack into the ast it generates and do some really cool syntax aware stuff! for example tree-edit uses a mix of the TS ast and logic programming to be able to strutually destructure, navigate and restructure the AST. In a sense it allows for structural selection, allowing you to wrap code with other code structures and a heck of a lot more! and this is not the end of it, in a sense the sky’s the limit
;;; Tree Sitter
(use-package! tree-sitter
:hook (prog-mode . turn-on-tree-sitter-mode)
:hook (tree-sitter-after-on . tree-sitter-hl-mode)
:config
(require 'tree-sitter-langs)
;; This makes every node a link to a section of code
(setq tree-sitter-debug-jump-buttons t
;; and this highlights the entire sub tree in your code
tree-sitter-debug-highlight-jump-region t))
That advice is no longer needed. I would just take the use-package! blocks from the module it should work the same. (maybe need to add in a :hook here and a (require tree-sitter-langs) there but overall it should be copy and paste
Thank you. So only this in the config for minimal tree sitter/syntax highlighting?
(use-package! tree-sitter
:hook (tree-sitter-after-on . tree-sitter-hl-mode)
:config
;; This makes every node a link to a section of code
(setq tree-sitter-debug-jump-buttons t
;; and this highlights the entire sub tree in your code
tree-sitter-debug-highlight-jump-region t))
(use-package! tree-sitter
:hook (prog-mode . turn-on-tree-sitter-mode)
:hook (tree-sitter-after-on . tree-sitter-hl-mode)
:config
(require 'tree-sitter-langs)
;; This makes every node a link to a section of code
(setq tree-sitter-debug-jump-buttons t
;; and this highlights the entire sub tree in your code
tree-sitter-debug-highlight-jump-region t))
The reason this advice is not needed is because if your using turn-on-tree-sitter-mode like in the snippet, it already ignores errors
here is them implementation
(defun turn-on-tree-sitter-mode ()
"Turn on `tree-sitter-mode' in a buffer, if possible."
;; FIX: Ignore only known errors. Log the rest, at least.
(ignore-errors
(tree-sitter-mode 1)))
I would argue that you should not need to use tree-sitter-mode as a hook because tree sitter already has a better hook function that accounts for this, the only times I need it when activating in a mode that does not have a hook. to demote all errors feels harder to debug.
BTW, I know its had some headway on the discord but the module has been merged into master! all of this is now moot because all you need to do is enable the module and add flags to the lang modules you want!