feat(treesitter): allow passing lang to InspectTree

This commit is contained in:
Maria José Solano
2025-03-11 21:54:25 -07:00
committed by Christian Clason
parent 092529ebbf
commit a94a2927d0

View File

@@ -9,17 +9,17 @@ do
end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
vim.api.nvim_create_user_command('InspectTree', function(cmd)
local opts = { lang = cmd.fargs[1] }
if cmd.mods ~= '' or cmd.count ~= 0 then
local count = cmd.count ~= 0 and cmd.count or ''
local new = cmd.mods ~= '' and 'new' or 'vnew'
vim.treesitter.inspect_tree({
command = ('%s %s%s'):format(cmd.mods, count, new),
})
else
vim.treesitter.inspect_tree()
opts.command = ('%s %s%s'):format(cmd.mods, count, new)
end
end, { desc = 'Inspect treesitter language tree for buffer', count = true })
vim.treesitter.inspect_tree(opts)
end, { desc = 'Inspect treesitter language tree for buffer', count = true, nargs = '?' })
vim.api.nvim_create_user_command('EditQuery', function(cmd)
vim.treesitter.query.edit(cmd.fargs[1])