aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/query.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-02-23 15:19:52 +0000
committerGitHub <noreply@github.com>2023-02-23 15:19:52 +0000
commit75e53341f37eeeda7d9be7f934249f7e5e4397e9 (patch)
treeb0b88f28c0ed701a9b2f13dbfe988061d48fa937 /runtime/lua/vim/treesitter/query.lua
parent86807157438240757199f925f538d7ad02322754 (diff)
downloadrneovim-75e53341f37eeeda7d9be7f934249f7e5e4397e9.tar.gz
rneovim-75e53341f37eeeda7d9be7f934249f7e5e4397e9.tar.bz2
rneovim-75e53341f37eeeda7d9be7f934249f7e5e4397e9.zip
perf(treesitter): smarter languagetree invalidation
Problem: Treesitter injections are slow because all injected trees are invalidated on every change. Solution: Implement smarter invalidation to avoid reparsing injected regions. - In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change. - Add valid flags for each region in self._regions. - Call on_bytes recursively for all children. - We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children. This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled.
Diffstat (limited to 'runtime/lua/vim/treesitter/query.lua')
-rw-r--r--runtime/lua/vim/treesitter/query.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 58a29f2fe0..13d98a0625 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -406,7 +406,7 @@ predicate_handlers['vim-match?'] = predicate_handlers['match?']
---@class TSMetadata
---@field [integer] TSMetadata
---@field [string] integer|string
----@field range Range
+---@field range Range4
---@alias TSDirective fun(match: TSMatch, _, _, predicate: any[], metadata: TSMetadata)