mirror of
https://github.com/neovim/neovim.git
synced 2026-02-19 01:48:30 +00:00
feat(treesitter)!: incremental injection parsing
Problem:
Treesitter highlighting is slow for large files with lots of injections.
Solution:
Only parse injections we are going to render during a redraw cycle.
---
- `LanguageTree:parse()` will no longer parse injections by default and
now requires an explicit range argument to be passed.
- `TSHighlighter` now parses injections incrementally during on_win
callbacks for the line range being rendered.
- Plugins which require certain injections to be parsed must run
`parser:parse({ start_row, end_row })` before using the tree.
This commit is contained in:
committed by
Lewis Russell
parent
5a25dcc5a4
commit
2ca076e45f
@@ -99,7 +99,7 @@ function TSTreeView:new(bufnr, lang)
|
||||
-- For each child tree (injected language), find the root of the tree and locate the node within
|
||||
-- the primary tree that contains that root. Add a mapping from the node in the primary tree to
|
||||
-- the root in the child tree to the {injections} table.
|
||||
local root = parser:parse()[1]:root()
|
||||
local root = parser:parse(true)[1]:root()
|
||||
local injections = {} ---@type table<integer,table>
|
||||
parser:for_each_child(function(child, lang_)
|
||||
child:for_each_tree(function(tree)
|
||||
|
||||
Reference in New Issue
Block a user