From 05de0f4fea237132ff3a9a5a35e9c711c4ece579 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 21 Feb 2023 17:03:04 +0100 Subject: [PATCH 1/3] docs(treesitter): fix parse errors --- runtime/lua/vim/treesitter.lua | 4 ++-- runtime/lua/vim/treesitter/languagetree.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index c1e5325519..c4df5b2d24 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -157,7 +157,7 @@ end --- Returns the node's range or an unpacked range table --- ----@param node_or_range (TSNode|table) Node or table of positions +---@param node_or_range (TSNode | table) Node or table of positions --- ---@return integer start_row ---@return integer start_col @@ -339,7 +339,7 @@ end --- - lang string|nil Parser language --- - ignore_injections boolean Ignore injected languages (default true) --- ----@return TSNode|nil under the cursor +---@return TSNode | nil Node at the given position ---@deprecated function M.get_node_at_pos(bufnr, row, col, opts) vim.deprecate('vim.treesitter.get_node_at_pos()', 'vim.treesitter.get_node()', '0.10') diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 81ad83db2c..c9fd4bb2ea 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -653,7 +653,7 @@ end ---@param range Range `{ start_line, start_col, end_line, end_col }` ---@param opts table|nil Optional keyword arguments: --- - ignore_injections boolean Ignore injected languages (default true) ----@return TSNode|nil Found node +---@return TSNode | nil Found node function LanguageTree:named_node_for_range(range, opts) local tree = self:tree_for_range(range, opts) if tree then From 1c37553476f268d08d290dfee1fa3da4135b54b4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 21 Feb 2023 17:00:48 +0100 Subject: [PATCH 2/3] test(help): drop treesitter parse error to 0 All parser errors have been fixed; make sure we don't introduce new ones. --- runtime/doc/treesitter. | 0 runtime/doc/treesitter.txt | 4 ++-- test/functional/lua/help_spec.lua | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 runtime/doc/treesitter. diff --git a/runtime/doc/treesitter. b/runtime/doc/treesitter. new file mode 100644 index 0000000000..e69de29bb2 diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 16de49029e..99fe55b6cb 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -528,7 +528,7 @@ get_node_range({node_or_range}) *vim.treesitter.get_node_range()* Returns the node's range or an unpacked range table Parameters: ~ - • {node_or_range} (|TSNode||table) Node or table of positions + • {node_or_range} (|TSNode| | table) Node or table of positions Return: ~ (integer) start_row @@ -1017,7 +1017,7 @@ LanguageTree:named_node_for_range({self}, {range}, {opts}) • {self} Return: ~ - |TSNode||nil Found node + |TSNode| | nil Found node LanguageTree:parse({self}) *LanguageTree:parse()* Parses all defined regions using a treesitter parser for the language this diff --git a/test/functional/lua/help_spec.lua b/test/functional/lua/help_spec.lua index b396e2ba30..d66d9f7fbe 100644 --- a/test/functional/lua/help_spec.lua +++ b/test/functional/lua/help_spec.lua @@ -21,9 +21,8 @@ describe(':help docs', function() ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles) eq({}, rv.invalid_links, 'invalid tags in :help docs') eq({}, rv.invalid_urls, 'invalid URLs in :help docs') - -- Check that parse errors did not increase wildly. - -- TODO: Fix all parse errors in :help files. - ok(rv.err_count < 250, '<250 parse errors', rv.err_count) + -- Check that parse errors did not increase. + ok(rv.err_count == 0, 'no parse errors', rv.err_count) end) it('gen_help_html.lua generates HTML', function() From 6dfbeb0d990d24657754463c6ab155c19e7f5f56 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 21 Feb 2023 17:39:29 +0100 Subject: [PATCH 3/3] docs: fix more treesitter parsing errors --- runtime/doc/diagnostic.txt | 8 ++++---- runtime/doc/lua-guide.txt | 2 +- runtime/doc/treesitter. | 0 runtime/doc/treesitter.txt | 7 +++---- runtime/lua/vim/treesitter.lua | 2 +- runtime/lua/vim/treesitter/query.lua | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 runtime/doc/treesitter. diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 7066a3739a..c661bf02bf 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -40,15 +40,15 @@ requires a namespace. *diagnostic-structure* A diagnostic is a Lua table with the following keys. Required keys are -indicated with (*): +indicated with (+): bufnr: Buffer number - lnum(*): The starting line of the diagnostic + lnum(+): The starting line of the diagnostic end_lnum: The final line of the diagnostic - col(*): The starting column of the diagnostic + col(+): The starting column of the diagnostic end_col: The final column of the diagnostic severity: The severity of the diagnostic |vim.diagnostic.severity| - message(*): The diagnostic text + message(+): The diagnostic text source: The source of the diagnostic code: The diagnostic code user_data: Arbitrary data plugins or users can add diff --git a/runtime/doc/lua-guide.txt b/runtime/doc/lua-guide.txt index 236905a077..8ea84f8c60 100644 --- a/runtime/doc/lua-guide.txt +++ b/runtime/doc/lua-guide.txt @@ -71,7 +71,7 @@ local keyword are not accessible outside of the command. This won't work: < You can also use `:lua=`, which is the same as `:lua vim.pretty_print(...)`, to conveniently check the value of a variable or a table: ->lua +>vim :lua=package < To run a Lua script in an external file, you can use the |:source| command diff --git a/runtime/doc/treesitter. b/runtime/doc/treesitter. deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 99fe55b6cb..3f505e5d19 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -505,8 +505,7 @@ get_captures_at_pos({bufnr}, {row}, {col}) • {col} (integer) Position column Return: ~ - table[] List of captures `{ capture = "capture name", metadata = { ... - } }` + table[] List of captures `{ capture = "name", metadata = { ... } }` get_node({opts}) *vim.treesitter.get_node()* Returns the smallest named node at the given position @@ -838,7 +837,7 @@ Query:iter_captures({self}, {node}, {source}, {start}, {stop}) -- typically useful info about the node: local type = node:type() -- type of the captured node local row1, col1, row2, col2 = node:range() -- range of the capture - ... use the info here ... + -- ... use the info here ... end < @@ -871,7 +870,7 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop}) local node_data = metadata[id] -- Node level metadata - ... use the info here ... + -- ... use the info here ... end end < diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index c4df5b2d24..44922bbc4d 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -218,7 +218,7 @@ end ---@param row integer Position row ---@param col integer Position column --- ----@return table[] List of captures `{ capture = "capture name", metadata = { ... } }` +---@return table[] List of captures `{ capture = "name", metadata = { ... } }` function M.get_captures_at_pos(bufnr, row, col) if bufnr == 0 then bufnr = a.nvim_get_current_buf() diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 83910316a6..58a29f2fe0 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -639,7 +639,7 @@ end --- -- typically useful info about the node: --- local type = node:type() -- type of the captured node --- local row1, col1, row2, col2 = node:range() -- range of the capture ---- ... use the info here ... +--- -- ... use the info here ... --- end --- --- @@ -693,7 +693,7 @@ end --- --- local node_data = metadata[id] -- Node level metadata --- ---- ... use the info here ... +--- -- ... use the info here ... --- end --- end ---