mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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:

committed by
GitHub

parent
6162269fa3
commit
2720d2c793
@@ -623,8 +623,8 @@ inspect_tree({opts}) *vim.treesitter.inspect_tree()*
|
|||||||
• winid (integer|nil): Window id to display the tree buffer
|
• winid (integer|nil): Window id to display the tree buffer
|
||||||
in. If omitted, a new window is created with {command}.
|
in. If omitted, a new window is created with {command}.
|
||||||
• command (string|nil): Vimscript command to create the
|
• command (string|nil): Vimscript command to create the
|
||||||
window. Default value is "topleft 60vnew". Only used when
|
window. Default value is "60vnew". Only used when {winid} is
|
||||||
{winid} is nil.
|
nil.
|
||||||
• title (string|fun(bufnr:integer):string|nil): Title of the
|
• title (string|fun(bufnr:integer):string|nil): Title of the
|
||||||
window. If a function, it accepts the buffer number of the
|
window. If a function, it accepts the buffer number of the
|
||||||
source buffer as its only argument and should return a
|
source buffer as its only argument and should return a
|
||||||
|
@@ -439,7 +439,7 @@ end
|
|||||||
--- - winid (integer|nil): Window id to display the tree buffer in. If omitted,
|
--- - winid (integer|nil): Window id to display the tree buffer in. If omitted,
|
||||||
--- a new window is created with {command}.
|
--- a new window is created with {command}.
|
||||||
--- - command (string|nil): Vimscript command to create the window. Default
|
--- - command (string|nil): Vimscript command to create the window. Default
|
||||||
--- value is "topleft 60vnew". Only used when {winid} is nil.
|
--- value is "60vnew". Only used when {winid} is nil.
|
||||||
--- - title (string|fun(bufnr:integer):string|nil): Title of the window. If a
|
--- - title (string|fun(bufnr:integer):string|nil): Title of the window. If a
|
||||||
--- function, it accepts the buffer number of the source buffer as its only
|
--- function, it accepts the buffer number of the source buffer as its only
|
||||||
--- argument and should return a string.
|
--- argument and should return a string.
|
||||||
@@ -465,7 +465,7 @@ function M.inspect_tree(opts)
|
|||||||
|
|
||||||
local w = opts.winid
|
local w = opts.winid
|
||||||
if not w then
|
if not w then
|
||||||
vim.cmd(opts.command or 'topleft 60vnew')
|
vim.cmd(opts.command or '60vnew')
|
||||||
w = a.nvim_get_current_win()
|
w = a.nvim_get_current_win()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -6,6 +6,15 @@ vim.api.nvim_create_user_command('Inspect', function(cmd)
|
|||||||
end
|
end
|
||||||
end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
|
end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('InspectTree', function()
|
vim.api.nvim_create_user_command('InspectTree', function(cmd)
|
||||||
vim.treesitter.inspect_tree()
|
if cmd.mods ~= '' or cmd.count ~= 0 then
|
||||||
end, { desc = 'Inspect treesitter language tree for buffer' })
|
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 })
|
||||||
|
Reference in New Issue
Block a user