mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user