fix(treesitter): InspectTree does not respect 'splitright' #22692

Problem:
vim.treesitter.inspect_tree() and :InspectTree does not respect 'splitright'.

Solution:
- Change the default `command` from `topleft 60vnew` to `60vnew`.
- Change :InspectTree to respect command mods (`:vertical`, count, etc.).

Closes #22656
This commit is contained in:
Yochem van Rosmalen
2023-03-17 12:41:57 +01:00
committed by GitHub
parent 6162269fa3
commit 2720d2c793
3 changed files with 16 additions and 7 deletions

View File

@@ -6,6 +6,15 @@ vim.api.nvim_create_user_command('Inspect', function(cmd)
end
end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
vim.api.nvim_create_user_command('InspectTree', function()
vim.treesitter.inspect_tree()
end, { desc = 'Inspect treesitter language tree for buffer' })
vim.api.nvim_create_user_command('InspectTree', function(cmd)
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()
end
end, { desc = 'Inspect treesitter language tree for buffer', count = true })