From 3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 16 Oct 2024 17:03:48 +0100 Subject: perf(validate): use lighter version - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number. --- runtime/lua/vim/treesitter/dev.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'runtime/lua/vim/treesitter/dev.lua') diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index 90c3720b80..7b522ca92b 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 {} -- cgit From 99acc9de559a2ea3b9de2b418dbcae774d1d9a75 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 3 Nov 2024 11:28:31 +0800 Subject: fix(treesitter): close InspectTree/EditQuery window on BufUnload (#31036) Problem: The window opened :InspectTree or :EditQuery isn't closed when the source buffer is unloaded, even though it is closed when the buffer is hidden. Solution: Also close the window on BufUnload. --- runtime/lua/vim/treesitter/dev.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/lua/vim/treesitter/dev.lua') diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index 7b522ca92b..d68a30cc11 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -527,7 +527,7 @@ function M.inspect_tree(opts) end, }) - api.nvim_create_autocmd('BufHidden', { + api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, { group = group, buffer = buf, once = true, @@ -665,10 +665,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) -- cgit From 86b737649bb8c51649a21033c0e365f53f2bc04a Mon Sep 17 00:00:00 2001 From: hykerr Date: Tue, 12 Nov 2024 12:26:07 +0100 Subject: fix(treesitter): add 'QuitPre' event to autocommands in inspect_tree Problem: Quitting source buffer for ```:InspectTree``` command raises ```E855``` when source buffer and tree views are the only open buffers. Solution: Add ```QuitPre``` event to autocmd handling closing/hiding the source buffer to close all open tree views. This allows nvim to quit when source and tree buffers are the only open windows. --- runtime/lua/vim/treesitter/dev.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/treesitter/dev.lua') diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index d68a30cc11..74d796f7fa 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -527,7 +527,7 @@ function M.inspect_tree(opts) end, }) - api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, { + api.nvim_create_autocmd({ 'BufHidden', 'BufUnload', 'QuitPre' }, { group = group, buffer = buf, once = true, -- cgit From 6ef80eb42c730e66e5a769f619e05b353c08c118 Mon Sep 17 00:00:00 2001 From: Hyker Date: Fri, 15 Nov 2024 04:00:18 +0100 Subject: fix(treesitter): keep treeview open if source window is still open #31198 Problem: When there is a tree view opened by :InspectTree and the source buffer is open in multiple windows, closing one of the source windows will lead to the tree view being closed as well. Regression by #31181. Solution: Check how many source windows are open when trying to quit one. If there are more than one, keep the tree view(s) open. If the only source window is closed, also close the tree view(s). fix #31196 --- runtime/lua/vim/treesitter/dev.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/treesitter/dev.lua') diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index 74d796f7fa..26817cdba5 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -530,12 +530,19 @@ function M.inspect_tree(opts) 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 -- cgit