-
Notifications
You must be signed in to change notification settings - Fork 47
Treesitter not updating or refreshing automatically as text changes #64
Comments
At the moment the updates rely on a tree-sitter highlighter to be active (typically by an active |
Oh... wow, interesting. Enabling the But I can't understand why highlight modules is mandatory. I didn't want to have it turned on because it conflicts with built-in (and custom) vim syntax files and I don't have much fine-grained control over it. Neither this was properly documented somewhere. Is this by design or just a practical limitation? I expect treesitter-based plugins that doesn't necessarily have something to do with highlight would still work nicely with dynamically-updated syntax tree, even if the |
Practical and current limitation: nvim-treesitter evolved from a syntax highlighting alternative. More fine-grained control is definitely a desideratum but requires somewhat extensive changes, not just to nvim-treesitter but also to tree-sitter integration in Neovim core and the legacy syntax engine. I will add the usual reminder here that tree-sitter support is still very much experimental and won't be stable for quite a while yet! |
So it looks like this is limitation of neovim's lua runtime API As a workaround, would be there any good recommended way for me to disable all the treesitter highlight groups (i.e., I don't want it overriding existing vim syntaxes)? For me, treesitter syntax for some filetypes I'm working on has some issues so I would prefer using legacy syntax files for some of them.
UPDATE 2: The above hack will make TS-highlight information (e.g., |
TSHighlighter uses You could also trigger the re-parse by an auto-command/timer. |
This is a bug of nvim-treesitter/playground. It should request a redraw when it does an update. |
In the current implementation of treesitter, the parse tree for the current buffer would not be automatically updated/refreshed when text changes, unless treesitter-highlight module is enabled. However, I don't want to use treesitter's highlight/syntax feature yet due to some issues and conflicts. To make the parse tree up-to-date as text changes, parser:parse() needs to be explicitly called in the absence of treesitter-highlight. Ref: nvim-treesitter/nvim-treesitter#2492
Describe the bug
Treesitter syntax tree does not update or refresh automatically as I update the buffer. Please see the video below.
To Reproduce
This is how I did when generating the video above:
$ nvim -u minimal.vim a.py
minimal.vim:
where treesitter.lua contains a minimal setup config, nothing special there.
Expected behavior
Treesitter syntax tree (shown from TSPlayground or nvim-gps) should update automatically. It seems that playground does update automatically when I insert new blank lines, but the syntax tree gets out of sync.
nvim-gps
does not recognize the new context (nested functions) that was typed after opening the buffer.Output of
:checkhealth nvim-treesitter
Output of
nvim --version
Version information:
tree-sitter -V
:tree-sitter 0.20.4
(installed through homebrew):TSUpdate
and all parsers are up-to-dateAdditional context
I thought this was a bug of nvim-gps, but it seems that it's the problem of my treesitter itself (ref: SmiteshP/nvim-gps#69) because playground is also not working.
I searched existing issues but haven't found anything relevant (e.g., nvim-treesitter/nvim-treesitter#78, nvim-treesitter/nvim-treesitter#235 are about highlights.)
This happens for all filetypes, not only python.
The text was updated successfully, but these errors were encountered: