diff options
author | Famiu Haque <famiuhaque@protonmail.com> | 2022-11-07 22:27:37 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@protonmail.com> | 2022-11-07 22:27:37 +0600 |
commit | c022140ec6a66402e405152054b6ab0141940419 (patch) | |
tree | fbc4603337fde297b580ad892457650a3fd33fc8 /src/nvim/api/command.c | |
parent | e9c1cb71f8a4d6d7818dcb5f71ac78bee431309a (diff) | |
download | rneovim-c022140ec6a66402e405152054b6ab0141940419.tar.gz rneovim-c022140ec6a66402e405152054b6ab0141940419.tar.bz2 rneovim-c022140ec6a66402e405152054b6ab0141940419.zip |
feat(api): add command name to Lua command callback opts
Adds a `name` key to the opts dict passed to Lua command callbacks
created using `nvim_create_user_command()`. This is useful for when
multiple commands use the same callback.
Note that this kind of behavior is not as strange as one might think,
even some internal Neovim commands reuse the same internal C function,
differing their behavior by checking the command name. `substitute`,
`smagic` and `snomagic` are examples of that.
This will also be useful for generalized Lua command preview functions
that can preview a wide range of commands, in which case knowing the
command name is necessary for the preview function to actually be able
to execute the command that it's supposed to preview.
Diffstat (limited to 'src/nvim/api/command.c')
-rw-r--r-- | src/nvim/api/command.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index 8cd2c0f8b8..752d3868d5 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -884,6 +884,7 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin /// @param command Replacement command to execute when this user command is executed. When called /// from Lua, the command can also be a Lua function. The function is called with a /// single table argument that contains the following keys: +/// - name: (string) Command name /// - args: (string) The args passed to the command, if any |<args>| /// - fargs: (table) The args split by unescaped whitespace (when more than one /// argument is allowed), if any |<f-args>| |