misc.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---@meta
  2. -- luacheck: no unused args
  3. error('Cannot require a meta file')
  4. ---@alias TSLoggerCallback fun(logtype: 'parse'|'lex', msg: string)
  5. ---@class TSParser: userdata
  6. ---@field parse fun(self: TSParser, tree: TSTree?, source: integer|string, include_bytes: boolean): TSTree, (Range4|Range6)[]
  7. ---@field reset fun(self: TSParser)
  8. ---@field included_ranges fun(self: TSParser, include_bytes: boolean?): integer[]
  9. ---@field set_included_ranges fun(self: TSParser, ranges: (Range6|TSNode)[])
  10. ---@field set_timeout fun(self: TSParser, timeout: integer)
  11. ---@field timeout fun(self: TSParser): integer
  12. ---@field _set_logger fun(self: TSParser, lex: boolean, parse: boolean, cb: TSLoggerCallback)
  13. ---@field _logger fun(self: TSParser): TSLoggerCallback
  14. ---@class TSQuery: userdata
  15. ---@field inspect fun(self: TSQuery): TSQueryInfo
  16. ---@class (exact) TSQueryInfo
  17. ---@field captures string[]
  18. ---@field patterns table<integer, (integer|string)[][]>
  19. --- @param lang string
  20. --- @return table
  21. vim._ts_inspect_language = function(lang) end
  22. ---@return integer
  23. vim._ts_get_language_version = function() end
  24. --- @param path string
  25. --- @param lang string
  26. --- @param symbol_name? string
  27. vim._ts_add_language_from_object = function(path, lang, symbol_name) end
  28. --- @param path string
  29. --- @param lang string
  30. vim._ts_add_language_from_wasm = function(path, lang) end
  31. ---@return integer
  32. vim._ts_get_minimum_language_version = function() end
  33. ---@param lang string Language to use for the query
  34. ---@param query string Query string in s-expr syntax
  35. ---@return TSQuery
  36. vim._ts_parse_query = function(lang, query) end
  37. ---@param lang string
  38. ---@return TSParser
  39. vim._create_ts_parser = function(lang) end
  40. --- @class TSQueryMatch: userdata
  41. --- @field captures fun(self: TSQueryMatch): table<integer,TSNode[]>
  42. local TSQueryMatch = {} -- luacheck: no unused
  43. --- @return integer match_id
  44. --- @return integer pattern_index
  45. function TSQueryMatch:info() end
  46. --- @class TSQueryCursor: userdata
  47. --- @field remove_match fun(self: TSQueryCursor, id: integer)
  48. local TSQueryCursor = {} -- luacheck: no unused
  49. --- @return integer capture
  50. --- @return TSNode captured_node
  51. --- @return TSQueryMatch match
  52. function TSQueryCursor:next_capture() end
  53. --- @return TSQueryMatch match
  54. function TSQueryCursor:next_match() end
  55. --- @param node TSNode
  56. --- @param query TSQuery
  57. --- @param start integer?
  58. --- @param stop integer?
  59. --- @param opts? { max_start_depth?: integer, match_limit?: integer}
  60. --- @return TSQueryCursor
  61. function vim._create_ts_querycursor(node, query, start, stop, opts) end