fix: resolve all remaining LuaLS warnings in src/

This commit is contained in:
Riccardo Mazzarini
2026-03-01 12:59:16 +01:00
parent 9204b7541d
commit 92b2a26772
19 changed files with 87 additions and 43 deletions

View File

@@ -10,7 +10,7 @@ local api_type = require('gen.api_types')
--- @class nvim.cdoc.parser.return
--- @field name string
--- @field type string
--- @field desc string
--- @field desc? string
--- @class nvim.cdoc.parser.note
--- @field desc string
@@ -25,7 +25,8 @@ local api_type = require('gen.api_types')
--- @field returns nvim.cdoc.parser.return[]
--- @field desc string
--- @field deprecated? true
--- @field since? string
--- @field deprecated_since? integer
--- @field since? string|integer
--- @field attrs? string[]
--- @field nodoc? true
--- @field notes? nvim.cdoc.parser.note[]
@@ -107,6 +108,8 @@ local function process_doc_line(line, state)
table.insert(cur_obj.params, state.last_doc_item)
elseif kind == 'return' then
cur_obj.returns = { {
name = '',
type = '',
desc = parsed.desc,
} }
state.last_doc_item_indent = nil
@@ -132,7 +135,7 @@ local function process_doc_line(line, state)
end
end
--- @param item table
--- @param item nvim.c_grammar.Proto
--- @param state nvim.cdoc.parser.State
local function process_proto(item, state)
state.cur_obj = state.cur_obj or {}
@@ -160,7 +163,11 @@ local function process_proto(item, state)
end
end
cur_obj.returns = cur_obj.returns or { {} }
cur_obj.returns = cur_obj.returns or { {
name = '',
type = '',
desc = nil,
} }
cur_obj.returns[1].type = api_type(item.return_type)
for _, a in ipairs({
@@ -191,7 +198,7 @@ end
local M = {}
--- @param filename string
--- @return {} classes
--- @return table<string,nvim.luacats.parser.class> classes
--- @return nvim.cdoc.parser.fun[] funs
--- @return string[] briefs
function M.parse(filename)
@@ -208,7 +215,7 @@ function M.parse(filename)
else
add_doc_lines_to_obj(state)
if item[1] == 'proto' then
process_proto(item, state)
process_proto(item --[[@as nvim.c_grammar.Proto]], state)
table.insert(funs, state.cur_obj)
end
local cur_obj = state.cur_obj