mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 03:35:02 -07:00
bd5008de07
Query patterns can contain quantifiers (e.g. (foo)+ @bar), so a single capture can map to multiple nodes. The iter_matches API can not handle this situation because the match table incorrectly maps capture indices to a single node instead of to an array of nodes. The match table should be updated to map capture indices to an array of nodes. However, this is a massively breaking change, so must be done with a proper deprecation period. `iter_matches`, `add_predicate` and `add_directive` must opt-in to the correct behavior for backward compatibility. This is done with a new "all" option. This option will become the default and removed after the 0.10 release. Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: MDeiml <matthias@deiml.net> Co-authored-by: Gregory Anders <greg@gpanders.com>
94 lines
4.0 KiB
Lua
94 lines
4.0 KiB
Lua
---@meta
|
|
error('Cannot require a meta file')
|
|
|
|
---@class TSNode: userdata
|
|
---@field id fun(self: TSNode): string
|
|
---@field tree fun(self: TSNode): TSTree
|
|
---@field range fun(self: TSNode, include_bytes: false?): integer, integer, integer, integer
|
|
---@field range fun(self: TSNode, include_bytes: true): integer, integer, integer, integer, integer, integer
|
|
---@field start fun(self: TSNode): integer, integer, integer
|
|
---@field end_ fun(self: TSNode): integer, integer, integer
|
|
---@field type fun(self: TSNode): string
|
|
---@field symbol fun(self: TSNode): integer
|
|
---@field named fun(self: TSNode): boolean
|
|
---@field missing fun(self: TSNode): boolean
|
|
---@field extra fun(self: TSNode): boolean
|
|
---@field child_count fun(self: TSNode): integer
|
|
---@field named_child_count fun(self: TSNode): integer
|
|
---@field child fun(self: TSNode, index: integer): TSNode?
|
|
---@field named_child fun(self: TSNode, index: integer): TSNode?
|
|
---@field descendant_for_range fun(self: TSNode, start_row: integer, start_col: integer, end_row: integer, end_col: integer): TSNode?
|
|
---@field named_descendant_for_range fun(self: TSNode, start_row: integer, start_col: integer, end_row: integer, end_col: integer): TSNode?
|
|
---@field parent fun(self: TSNode): TSNode?
|
|
---@field next_sibling fun(self: TSNode): TSNode?
|
|
---@field prev_sibling fun(self: TSNode): TSNode?
|
|
---@field next_named_sibling fun(self: TSNode): TSNode?
|
|
---@field prev_named_sibling fun(self: TSNode): TSNode?
|
|
---@field named_children fun(self: TSNode): TSNode[]
|
|
---@field has_changes fun(self: TSNode): boolean
|
|
---@field has_error fun(self: TSNode): boolean
|
|
---@field sexpr fun(self: TSNode): string
|
|
---@field equal fun(self: TSNode, other: TSNode): boolean
|
|
---@field iter_children fun(self: TSNode): fun(): TSNode, string
|
|
---@field field fun(self: TSNode, name: string): TSNode[]
|
|
---@field byte_length fun(self: TSNode): integer
|
|
local TSNode = {}
|
|
|
|
---@param query TSQuery
|
|
---@param captures true
|
|
---@param start? integer
|
|
---@param end_? integer
|
|
---@param opts? table
|
|
---@return fun(): integer, TSNode, TSMatch
|
|
function TSNode:_rawquery(query, captures, start, end_, opts) end
|
|
|
|
---@param query TSQuery
|
|
---@param captures false
|
|
---@param start? integer
|
|
---@param end_? integer
|
|
---@param opts? table
|
|
---@return fun(): integer, TSMatch
|
|
function TSNode:_rawquery(query, captures, start, end_, opts) end
|
|
|
|
---@alias TSLoggerCallback fun(logtype: 'parse'|'lex', msg: string)
|
|
|
|
---@class TSParser: userdata
|
|
---@field parse fun(self: TSParser, tree: TSTree?, source: integer|string, include_bytes: true): TSTree, Range6[]
|
|
---@field parse fun(self: TSParser, tree: TSTree?, source: integer|string, include_bytes: false|nil): TSTree, Range4[]
|
|
---@field reset fun(self: TSParser)
|
|
---@field included_ranges fun(self: TSParser, include_bytes: boolean?): integer[]
|
|
---@field set_included_ranges fun(self: TSParser, ranges: (Range6|TSNode)[])
|
|
---@field set_timeout fun(self: TSParser, timeout: integer)
|
|
---@field timeout fun(self: TSParser): integer
|
|
---@field _set_logger fun(self: TSParser, lex: boolean, parse: boolean, cb: TSLoggerCallback)
|
|
---@field _logger fun(self: TSParser): TSLoggerCallback
|
|
|
|
---@class TSTree: userdata
|
|
---@field root fun(self: TSTree): TSNode
|
|
---@field edit fun(self: TSTree, _: integer, _: integer, _: integer, _: integer, _: integer, _: integer, _: integer, _: integer, _:integer)
|
|
---@field copy fun(self: TSTree): TSTree
|
|
---@field included_ranges fun(self: TSTree, include_bytes: true): Range6[]
|
|
---@field included_ranges fun(self: TSTree, include_bytes: false): Range4[]
|
|
|
|
---@class TSQuery: userdata
|
|
---@field inspect fun(self: TSQuery): TSQueryInfo
|
|
|
|
---@class (exact) TSQueryInfo
|
|
---@field captures string[]
|
|
---@field patterns table<integer, (integer|string)[][]>
|
|
|
|
---@return integer
|
|
vim._ts_get_language_version = function() end
|
|
|
|
---@return integer
|
|
vim._ts_get_minimum_language_version = function() end
|
|
|
|
---@param lang string Language to use for the query
|
|
---@param query string Query string in s-expr syntax
|
|
---@return TSQuery
|
|
vim._ts_parse_query = function(lang, query) end
|
|
|
|
---@param lang string
|
|
---@return TSParser
|
|
vim._create_ts_parser = function(lang) end
|