aboutsummaryrefslogtreecommitdiff
path: root/scripts/lua2dox.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-02-04 14:58:38 +0000
committerGitHub <noreply@github.com>2023-02-04 14:58:38 +0000
commit9a5678463c96baf3b39cb3083ddf0da87d39aa23 (patch)
treeb0a8babd95fb7665ab107271467d6d5de12e511b /scripts/lua2dox.lua
parent69bb145cea56067e6e82ed0a130a51c0d611e540 (diff)
downloadrneovim-9a5678463c96baf3b39cb3083ddf0da87d39aa23.tar.gz
rneovim-9a5678463c96baf3b39cb3083ddf0da87d39aa23.tar.bz2
rneovim-9a5678463c96baf3b39cb3083ddf0da87d39aa23.zip
fix(treesitter): fix most diagnostics
Diffstat (limited to 'scripts/lua2dox.lua')
-rw-r--r--scripts/lua2dox.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua
index 19f8f8141d..fc0e915307 100644
--- a/scripts/lua2dox.lua
+++ b/scripts/lua2dox.lua
@@ -286,7 +286,12 @@ local function checkComment4fn(Fn_magic, MagicLines)
return fn_magic
end
-local types = { 'number', 'string', 'table', 'list', 'boolean', 'function' }
+local types = { 'integer', 'number', 'string', 'table', 'list', 'boolean', 'function' }
+
+local tagged_types = { 'TSNode', 'LanguageTree' }
+
+-- Document these as 'table'
+local alias_types = { 'Range' }
--! \brief run the filter
function TLua2DoX_filter.readfile(this, AppStamp, Filename)
@@ -320,7 +325,12 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename)
offset = 1
end
- if string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment
+ if vim.startswith(line, '---@cast')
+ or vim.startswith(line, '---@diagnostic')
+ or vim.startswith(line, '---@type') then
+ -- Ignore LSP directives
+ outStream:writeln('// gg:"' .. line .. '"')
+ elseif string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment
state = 'in_magic_comment'
local magic = string.sub(line, 4 + offset)
@@ -366,6 +376,17 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename)
magic_split[type_index] = magic_split[type_index]:gsub(k, v)
end
end
+
+ for _, type in ipairs(tagged_types) do
+ magic_split[type_index] =
+ magic_split[type_index]:gsub(type, '|%1|')
+ end
+
+ for _, type in ipairs(alias_types) do
+ magic_split[type_index] =
+ magic_split[type_index]:gsub('^'..type..'$', 'table')
+ end
+
-- surround some types by ()
for _, type in ipairs(types) do
magic_split[type_index] =
@@ -373,6 +394,8 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename)
magic_split[type_index] =
magic_split[type_index]:gsub('^(' .. type .. '):?$', '(%1)')
end
+
+
end
magic = table.concat(magic_split, ' ')