neovim

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

tsquery.lua (1905B)


      1 ---@meta
      2 -- luacheck: no unused args
      3 error('Cannot require a meta file')
      4 
      5 -- This could be documented as a module @brief like tsnode/tstree, but without
      6 -- its own section header documenting it as a class ensures it still gets a helptag.
      7 
      8 --- Reference to an object held by the treesitter library that is used as a
      9 --- component of the |vim.treesitter.Query| for language feature support.
     10 --- See |treesitter-query| for more about queries or |vim.treesitter.query.parse()|
     11 --- for an example of how to obtain a query object.
     12 ---
     13 ---@class TSQuery: userdata
     14 local TSQuery = {} -- luacheck: no unused
     15 
     16 --- Get information about the query's patterns and captures.
     17 ---@nodoc
     18 ---@return TSQueryInfo
     19 function TSQuery:inspect() end
     20 
     21 --- Disable a specific capture in this query; once disabled the capture cannot be re-enabled.
     22 --- {capture_name} should not include a leading "@".
     23 ---
     24 --- Example: To disable the `@variable.parameter` capture from the vimdoc highlights query:
     25 --- ```lua
     26 --- local query = vim.treesitter.query.get('vimdoc', 'highlights')
     27 --- query.query:disable_capture("variable.parameter")
     28 --- vim.treesitter.get_parser():parse()
     29 --- ```
     30 ---@param capture_name string
     31 function TSQuery:disable_capture(capture_name) end
     32 
     33 --- Disable a specific pattern in this query; once disabled the pattern cannot be re-enabled.
     34 --- The {pattern_index} for a particular match can be obtained with |:Inspect!|, or by reading
     35 --- the source of the query (i.e. from |vim.treesitter.query.get_files()|).
     36 ---
     37 --- Example: To disable `|` links in vimdoc but keep other `@markup.link`s highlighted:
     38 --- ```lua
     39 --- local link_pattern = 9 -- from :Inspect!
     40 --- local query = vim.treesitter.query.get('vimdoc', 'highlights')
     41 --- query.query:disable_pattern(link_pattern)
     42 --- local tree = vim.treesitter.get_parser():parse()[1]
     43 --- ```
     44 ---@param pattern_index integer
     45 function TSQuery:disable_pattern(pattern_index) end