aboutsummaryrefslogtreecommitdiff
path: root/runtime/plugin
diff options
context:
space:
mode:
authorYochem van Rosmalen <yochem+git@icloud.com>2023-03-17 12:41:57 +0100
committerGitHub <noreply@github.com>2023-03-17 04:41:57 -0700
commit2720d2c793b22e6c0c8719e5592922619fffdf7a (patch)
tree5a4b44b1c490e48485b88703bce3c56953addf3e /runtime/plugin
parent6162269fa3107b23fd18c6c6d0e3e8fb73cfb45e (diff)
downloadrneovim-2720d2c793b22e6c0c8719e5592922619fffdf7a.tar.gz
rneovim-2720d2c793b22e6c0c8719e5592922619fffdf7a.tar.bz2
rneovim-2720d2c793b22e6c0c8719e5592922619fffdf7a.zip
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
Diffstat (limited to 'runtime/plugin')
-rw-r--r--runtime/plugin/nvim.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/plugin/nvim.lua b/runtime/plugin/nvim.lua
index e4b099f7ad..0a33826b82 100644
--- a/runtime/plugin/nvim.lua
+++ b/runtime/plugin/nvim.lua
@@ -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 })