vim-patch:9.1.0547: No way to get the arity of a Vim function (#29638)

Problem:  No way to get the arity of a Vim function
          (Austin Ziegler)
Solution: Enhance get() Vim script function to return the function
          argument info using get(func, "arity") (LemonBoy)

fixes: vim/vim#15097
closes: vim/vim#15109

48b7d05a4f

Co-authored-by: LemonBoy <thatlemon@gmail.com>
This commit is contained in:
zeertzjq
2024-07-10 08:07:16 +08:00
committed by GitHub
parent f3c7fb9db1
commit 545aafbeb8
8 changed files with 168 additions and 26 deletions

View File

@ -432,14 +432,15 @@ local function render_eval_meta(f, fun, write)
end
--- @param name string
--- @param name_tag boolean
--- @param fun vim.EvalFn
--- @param write fun(line: string)
local function render_sig_and_tag(name, fun, write)
local function render_sig_and_tag(name, name_tag, fun, write)
if not fun.signature then
return
end
local tags = { '*' .. name .. '()*' }
local tags = name_tag and { '*' .. name .. '()*' } or {}
if fun.tags then
for _, t in ipairs(fun.tags) do
@ -447,6 +448,11 @@ local function render_sig_and_tag(name, fun, write)
end
end
if #tags == 0 then
write(fun.signature)
return
end
local tag = table.concat(tags, ' ')
local siglen = #fun.signature
local conceal_offset = 2 * (#tags - 1)
@ -472,11 +478,7 @@ local function render_eval_doc(f, fun, write)
return
end
if f:find('__%d+$') then
write(fun.signature)
else
render_sig_and_tag(fun.name or f, fun, write)
end
render_sig_and_tag(fun.name or f, not f:find('__%d+$'), fun, write)
if not fun.desc then
return