runtime(doc): Fix documentation for getinfo()

Problem:  The documentation for getinfo() is hard to understand.
Solution: fix it.

closes: #21475

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi authored and Christian Brabandt committed 2026-10-11 17:31:08 +00:00
1 parent 413999d2ef
commit 99b9dd00cd
1 file changed
+75 -59
+75 -59
View File
@@ -4746,7 +4746,7 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
function or an option that this Vim was built without and for
an Ex command that it does not implement. The other items
depend on {kind}, and so do the items of the optional Dict
{opts}; an item of {opts} for another {kind} is an error.
{opts}. An item of {opts} for another {kind} is an error.
"function" a built-in function, or a user defined
function when there is no built-in one with
@@ -4767,16 +4767,18 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
name the name of the argument as in the
help, missing when the help does not
name it
types the types the argument accepts, a List
of |vim9-types|; "any" for an argument
that is not checked or is checked
against another argument
types the types the argument accepts as a
List of Strings, see |vim9-types|;
"any" for an argument that is not
checked or is checked against another
argument
For a function without a maximum the last item
is for all the remaining arguments.
returns the type of the returned value when the
arguments are of type "any", "void" when there
is none. Also "any" when the type depends on
the number of arguments.
returns the type of the returned value as a String,
or "void" when the function returns nothing,
or "any" when the type depends on the
arguments and "argtypes" in {opts} is not
given
Example: >
echo getinfo('function', 'strlen')
@@ -4787,34 +4789,41 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
'types': ['string', 'number']}],
'returns': 'number'}
With the "argtypes" item of {opts}, a List of
|vim9-types| for the arguments, "returns" is the
type for arguments of those types, the same as what
a |:def| function is compiled with. Required
arguments that are not in the List are of type
"any". It is an error to give more types than the
maximum number of arguments or a type that is not
recognized. The types are not checked against
"args". Example: >
When {opts} has an "argtypes" item with a List of
|vim9-types|, "returns" is the type for a call with
arguments of those types. A required argument that is
not in the List is taken as "any". Giving more types
than "maxargs" or an unknown type is an error. A type
that the argument does not accept is not checked.
Example: >
let opts = {'argtypes': ['list<number>']}
echo getinfo('function', 'sort', opts).returns
< list<number>
For a user defined function:
name the name of the function, "<SNR>12_Func" for a
script-local one
name the name of the function, with the script ID
in front for a script-local function, as in
"<SNR>12_Func"
kind "function" for |:function|, "def" for |:def|
args a List with a Dict for each argument:
name the name of the argument
type the type for "def", "any" for
"function"
default the expression for the default value,
missing when there is none
varargs only when the function accepts more arguments:
a Dict with "name", empty for "...", and
"type", "list<any>" for "function"
returns the return type for "def", "any" for
"function"
type the type as a String, see
|vim9-types|; "any" for a function
defined with |:function|
default the expression for the default value
as a String, only present when there
is one
varargs a Dict for the variable arguments |...|,
only present when the function has them:
name the name of the arguments, or an empty
String for "..."
type the type as a String, or "list<any>"
for a function defined with
|:function|
returns the type of the returned value as a String,
or "void" when the function returns nothing,
or "any" for a function defined with
|:function|
abort |TRUE| when the function aborts on an error,
see |:func-abort|
range |TRUE| when the function takes a range, see
@@ -4835,46 +4844,50 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
'range': v:false, 'dict': v:false,
'closure': v:false, 'sid': 1, 'lnum': 1}
"command" an Ex command, also with an abbreviation; a
user defined command is found first, as with
`exists()`. The Dict is empty for an
"command" an Ex command. {name} can be abbreviated.
A user defined command is found first, as
with |exists()|. The Dict is empty for an
ambiguous abbreviation.
name the full name of the command
kind "builtin", "modifier" for a command modifier
like `:silent`, or "user" for a user defined
command
nargs the arguments as for |:command-nargs|: "0",
"1", "_", "*", "?" or "+"
kind "builtin" for a built-in command, "modifier"
for a command modifier like |:silent|, or
"user" for a user defined command
nargs a String with the number of arguments as
for |:command-nargs|: "0", "1", "_", "*",
"?" or "+"
range |FALSE| when a range is not allowed, otherwise
the default: "." for the cursor line, "%" for
the whole buffer or a Number as with
the default range: "." for the cursor line,
"%" for the whole buffer or a Number as with
|:command-range|
count |FALSE| when a count is not allowed, otherwise
the default count
count |FALSE| when a count is not allowed as
with |:command-count|, otherwise the
default count as a Number
bang |TRUE| when a "!" after the name is allowed
bar |TRUE| when "|" ends the command, see |:bar|
register
|TRUE| when a register name is accepted
addr what a range refers to, as for
|:command-addr|; a builtin command can also
have "none", "tabs_relative", "quickfix_valid"
or "unsigned"
addr a String with what a range refers to: a
value of |:command-addr|, or for a built-in
command also "none", "tabs_relative",
"quickfix_valid" or "unsigned"
Only for "user":
buffer |TRUE| for a buffer-local command
complete
the completion as for |:command-complete|,
empty when there is none
a String with the completion as for
|:command-complete|, or an empty String when
there is none
definition
the replacement text
sid the script ID where the command was defined
lnum the line number in that script
With the "vim9" item of {opts}, |TRUE| finds the
command as in |Vim9| script, where an abbreviation is
not accepted and some commands do not exist, |FALSE|
as in legacy Vim script. Without it the context of
the caller is used.
When {opts} has a "vim9" item that is |TRUE|, the
command is found as in |Vim9| script: an abbreviation
is not accepted and some commands do not exist. When
it is |FALSE|, the command is found as in legacy Vim
script. Without it the context of the caller is
used.
Example: >
echo getinfo('command', 's')
@@ -4883,15 +4896,18 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
'count': v:false, 'bang': v:false, 'bar': v:false,
'register': v:false, 'addr': 'lines'}
"option" an option, also one that is not supported in
this Vim, see |hidden-options|
"option" an option. An option that is not supported
in this Vim is also found, see
|hidden-options|.
name the full name of the option
shortname
the abbreviation, empty when there is none
the abbreviation, or an empty String when
there is none
type "bool", "number" or "string"
scope "global", "window", "buffer", "global-window"
or "global-buffer", see |global-local|
default the default value
default the Vim default value as a Boolean, Number
or String to match "type"
Example: >
echo getinfo('option', 'tw')
@@ -4900,9 +4916,9 @@ getinfo({kind}, {name} [, {opts}]) *getinfo()*
'scope': 'buffer', 'default': 0}
"vimvar" a predefined Vim variable, see |v:var|.
{name} includes the "v:".
name the name of the variable, with the "v:"
type the type of the variable, see |vim9-types|
{name} must start with "v:", as in "v:count".
name the name of the variable including the "v:"
type the type as a String, see |vim9-types|
readonly
|TRUE| when the variable cannot be set
compat |TRUE| when the variable can also be used