mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 14:55:33 +00:00
feat(treesitter): allow disabling captures and patterns on TSQuery (#32790)
Problem: Cannot disable individual captures and patterns in treesitter queries. Solution: * Expose the corresponding tree-sitter API functions for `TSQuery` object. * Add documentation for `TSQuery`. * Return the pattern ID from `get_captures_at_pos()` (and hence `:Inspect!`).
This commit is contained in:
@@ -10,7 +10,6 @@ local EXTENDS_FORMAT = '^;+%s*extends%s*$'
|
||||
|
||||
local M = {}
|
||||
|
||||
---@nodoc
|
||||
---Parsed query, see |vim.treesitter.query.parse()|
|
||||
---
|
||||
---@class vim.treesitter.Query
|
||||
@@ -344,9 +343,10 @@ api.nvim_create_autocmd('OptionSet', {
|
||||
|
||||
--- Parses a {query} string and returns a `Query` object (|lua-treesitter-query|), which can be used
|
||||
--- to search the tree for the query patterns (via |Query:iter_captures()|, |Query:iter_matches()|),
|
||||
--- or inspect the query via these fields:
|
||||
--- or inspect/modify the query via these fields:
|
||||
--- - `captures`: a list of unique capture names defined in the query (alias: `info.captures`).
|
||||
--- - `info.patterns`: information about predicates.
|
||||
--- - `query`: the underlying |TSQuery| which can be used to disable patterns or captures.
|
||||
---
|
||||
--- Example:
|
||||
--- ```lua
|
||||
|
||||
Reference in New Issue
Block a user