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

This commit is contained in:
Christian Clason 2023-03-02 18:03:11 +01:00 committed by GitHub
parent b0b4c31097
commit f449121764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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:

View File

@ -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.

View File

@ -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' })