aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/dev.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:15:05 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-25 19:27:38 +0000
commitc5d770d311841ea5230426cc4c868e8db27300a8 (patch)
treedd21f70127b4b8b5f109baefc8ecc5016f507c91 /runtime/lua/vim/treesitter/dev.lua
parent9be89f131f87608f224f0ee06d199fcd09d32176 (diff)
parent081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff)
downloadrneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2
rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/lua/vim/treesitter/dev.lua')
-rw-r--r--runtime/lua/vim/treesitter/dev.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua
index 90c3720b80..26817cdba5 100644
--- a/runtime/lua/vim/treesitter/dev.lua
+++ b/runtime/lua/vim/treesitter/dev.lua
@@ -330,9 +330,7 @@ end
---
--- @param opts vim.treesitter.dev.inspect_tree.Opts?
function M.inspect_tree(opts)
- vim.validate({
- opts = { opts, 't', true },
- })
+ vim.validate('opts', opts, 'table', true)
opts = opts or {}
@@ -529,15 +527,22 @@ function M.inspect_tree(opts)
end,
})
- api.nvim_create_autocmd('BufHidden', {
+ api.nvim_create_autocmd({ 'BufHidden', 'BufUnload', 'QuitPre' }, {
group = group,
buffer = buf,
- once = true,
callback = function()
+ -- don't close inpector window if source buffer
+ -- has more than one open window
+ if #vim.fn.win_findbuf(buf) > 1 then
+ return
+ end
+
-- close all tree windows
for _, window in pairs(vim.fn.win_findbuf(b)) do
close_win(window)
end
+
+ return true
end,
})
end
@@ -667,10 +672,10 @@ function M.edit_query(lang)
api.nvim_buf_clear_namespace(query_buf, edit_ns, 0, -1)
end,
})
- api.nvim_create_autocmd('BufHidden', {
+ api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, {
group = group,
buffer = buf,
- desc = 'Close the editor window when the source buffer is hidden',
+ desc = 'Close the editor window when the source buffer is hidden or unloaded',
once = true,
callback = function()
close_win(query_win)