aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/languagetree.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/treesitter/languagetree.lua')
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 6d47ed8365..a374974dca 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -35,6 +35,7 @@ function LanguageTree.new(source, lang, opts)
_callbacks = {
changedtree = {},
bytes = {},
+ detach = {},
child_added = {},
child_removed = {}
},
@@ -397,6 +398,11 @@ function LanguageTree:_on_bytes(bufnr, changed_tick,
new_row, new_col, new_byte)
end
+function LanguageTree:_on_detach(...)
+ self:invalidate()
+ self:_do_callback('detach', ...)
+end
+
--- Registers callbacks for the parser
-- @param cbs An `nvim_buf_attach`-like table argument with the following keys :
-- `on_bytes` : see `nvim_buf_attach`, but this will be called _after_ the parsers callback.
@@ -416,6 +422,10 @@ function LanguageTree:register_cbs(cbs)
table.insert(self._callbacks.bytes, cbs.on_bytes)
end
+ if cbs.on_detach then
+ table.insert(self._callbacks.detach, cbs.on_detach)
+ end
+
if cbs.on_child_added then
table.insert(self._callbacks.child_added, cbs.on_child_added)
end