aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-10 08:07:16 +0800
committerGitHub <noreply@github.com>2024-07-10 08:07:16 +0800
commit545aafbeb80eb52c182ce139800489b392a12d0d (patch)
tree580a4c7a0f42bddae3b4577054b8758906d4d631 /runtime
parentf3c7fb9db176f32606e83eb47cc7549300191d2f (diff)
downloadrneovim-545aafbeb80eb52c182ce139800489b392a12d0d.tar.gz
rneovim-545aafbeb80eb52c182ce139800489b392a12d0d.tar.bz2
rneovim-545aafbeb80eb52c182ce139800489b392a12d0d.zip
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 https://github.com/vim/vim/commit/48b7d05a4f88c4326bd5d7a73a523f2d953b3e51 Co-authored-by: LemonBoy <thatlemon@gmail.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/builtin.txt31
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua23
2 files changed, 40 insertions, 14 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 648598fb3f..334531cec7 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -2028,17 +2028,17 @@ garbagecollect([{atexit}]) *garbagecollect()*
it's safe to perform. This is when waiting for the user to
type a character.
-get({list}, {idx} [, {default}]) *get()*
+get({list}, {idx} [, {default}]) *get()* *get()-list*
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
-get({blob}, {idx} [, {default}])
+get({blob}, {idx} [, {default}]) *get()-blob*
Get byte {idx} from |Blob| {blob}. When this byte is not
available return {default}. Return -1 when {default} is
omitted.
-get({dict}, {key} [, {default}])
+get({dict}, {key} [, {default}]) *get()-dict*
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
{default} is omitted. Useful example: >vim
@@ -2046,13 +2046,26 @@ get({dict}, {key} [, {default}])
< This gets the value of g:var_name if it exists, and uses
"default" when it does not exist.
-get({func}, {what})
- Get item {what} from Funcref {func}. Possible values for
+get({func}, {what}) *get()-func*
+ Get item {what} from |Funcref| {func}. Possible values for
{what} are:
- "name" The function name
- "func" The function
- "dict" The dictionary
- "args" The list with arguments
+ "name" The function name
+ "func" The function
+ "dict" The dictionary
+ "args" The list with arguments
+ "arity" A dictionary with information about the number of
+ arguments accepted by the function (minus the
+ {arglist}) with the following fields:
+ required the number of positional arguments
+ optional the number of optional arguments,
+ in addition to the required ones
+ varargs |TRUE| if the function accepts a
+ variable number of arguments |...|
+
+ Note: There is no error, if the {arglist} of
+ the Funcref contains more arguments than the
+ Funcref expects, it's not validated.
+
Returns zero on error.
getbufinfo([{buf}]) *getbufinfo()*
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 34a3addb57..d9bd683bbb 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -2523,12 +2523,25 @@ function vim.fn.get(blob, idx, default) end
--- @return any
function vim.fn.get(dict, key, default) end
---- Get item {what} from Funcref {func}. Possible values for
+--- Get item {what} from |Funcref| {func}. Possible values for
--- {what} are:
---- "name" The function name
---- "func" The function
---- "dict" The dictionary
---- "args" The list with arguments
+--- "name" The function name
+--- "func" The function
+--- "dict" The dictionary
+--- "args" The list with arguments
+--- "arity" A dictionary with information about the number of
+--- arguments accepted by the function (minus the
+--- {arglist}) with the following fields:
+--- required the number of positional arguments
+--- optional the number of optional arguments,
+--- in addition to the required ones
+--- varargs |TRUE| if the function accepts a
+--- variable number of arguments |...|
+---
+--- Note: There is no error, if the {arglist} of
+--- the Funcref contains more arguments than the
+--- Funcref expects, it's not validated.
+---
--- Returns zero on error.
---
--- @param func function