neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit f449121764c19cebda7b8b2c970b76bc8121bae7
parent b0b4c310973c2b419350e3c05c772596b1c334e9
Author: Christian Clason <c.clason@uni-graz.at>
Date:   Thu,  2 Mar 2023 18:03:11 +0100

feat(treesitter): add :InspectTree command (#22477)


Diffstat:
Mruntime/doc/news.txt | 5+++--
Mruntime/doc/treesitter.txt | 2++
Mruntime/lua/vim/treesitter.lua | 2++
Mruntime/plugin/nvim.lua | 4++++
4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt @@ -89,8 +89,9 @@ The following new APIs or features were added. See |lsp-semantic_tokens| for more information. -• |vim.treesitter.inspect_tree()| opens a split window showing a text - representation of the nodes in a language tree for the current buffer. +• |vim.treesitter.inspect_tree()| and |:InspectTree| opens a split window + showing a text representation of the nodes in a language tree for the current + buffer. • Added support for the `willSave` and `willSaveWaitUntil` capabilities to the LSP client. `willSaveWaitUntil` allows a server to modify a document before it diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt @@ -603,6 +603,8 @@ inspect_tree({opts}) *vim.treesitter.inspect_tree()* to toggle the display of the source language of each node, and press <Enter> to jump to the node under the cursor in the source buffer. + Can also be shown with `:InspectTree`. *:InspectTree* + Parameters: ~ • {opts} (table|nil) Optional options table with the following possible keys: diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua @@ -424,6 +424,8 @@ end --- display of the source language of each node, and press <Enter> to jump to the node under the --- cursor in the source buffer. --- +--- Can also be shown with `:InspectTree`. *:InspectTree* +--- ---@param opts table|nil Optional options table with the following possible keys: --- - lang (string|nil): The language of the source buffer. If omitted, the --- filetype of the source buffer is used. diff --git a/runtime/plugin/nvim.lua b/runtime/plugin/nvim.lua @@ -5,3 +5,7 @@ vim.api.nvim_create_user_command('Inspect', function(cmd) vim.show_pos() 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' })