Skip to content

Commit

Permalink
Add inspect_tree function
Browse files Browse the repository at this point in the history
  • Loading branch information
Akmadan23 committed Nov 4, 2023
1 parent 2a6a2a9 commit 1330951
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config/nvim/lua/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,22 @@ M.inspect_object = function()
end)
end

local trees = {}

--- Toggle layer for vim.treesitter.inspect_tree
M.inspect_tree = function()
local winnr = vim.api.nvim_get_current_win()

for i, t in ipairs(trees) do
if vim.tbl_contains(t, winnr) then
vim.api.nvim_win_close(t[2], false)
table.remove(trees, i)
return
end
end

vim.treesitter.inspect_tree()
table.insert(trees, { winnr, vim.api.nvim_get_current_win() })
end

return M

0 comments on commit 1330951

Please sign in to comment.