fix(api): force redefinition of user commands by default (#16918)

This commit is contained in:
Gregory Anders
2022-01-04 11:51:45 -07:00
committed by GitHub
parent 0b0c4f7dfa
commit 39238435db
3 changed files with 14 additions and 13 deletions

View File

@@ -667,14 +667,17 @@ nvim_add_user_command({name}, {command}, {*opts})
{opts} Optional command attributes. See {opts} Optional command attributes. See
|command-attributes| for more details. To use |command-attributes| for more details. To use
boolean attributes (such as |:command-bang| or boolean attributes (such as |:command-bang| or
|:command-bar|) set the value to "true". When |:command-bar|) set the value to "true". In
using a Lua function for {command} you can also addition to the string options listed in
provide a "desc" key that will be displayed |:command-complete|, the "complete" key also
when listing commands. In addition to the accepts a Lua function which works like the
string options listed in |:command-complete|, "customlist" completion mode
the "complete" key also accepts a Lua function |:command-completion-customlist|. Additional
which works like the "customlist" completion parameters:
mode |:command-completion-customlist|. • desc: (string) Used for listing the command
when a Lua function is used for {command}.
• force: (boolean, default true) Override any
previous definition.
nvim_call_atomic({calls}) *nvim_call_atomic()* nvim_call_atomic({calls}) *nvim_call_atomic()*
Calls many API methods atomically. Calls many API methods atomically.

View File

@@ -1505,7 +1505,7 @@ void add_user_command(String name, Object command, Dict(user_command) *opts, int
goto err; goto err;
} }
bool force = api_object_to_bool(opts->force, "force", false, err); bool force = api_object_to_bool(opts->force, "force", true, err);
if (ERROR_SET(err)) { if (ERROR_SET(err)) {
goto err; goto err;
} }

View File

@@ -2396,12 +2396,10 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
/// boolean attributes (such as |:command-bang| or |:command-bar|) set the value to /// boolean attributes (such as |:command-bang| or |:command-bar|) set the value to
/// "true". In addition to the string options listed in |:command-complete|, the /// "true". In addition to the string options listed in |:command-complete|, the
/// "complete" key also accepts a Lua function which works like the "customlist" /// "complete" key also accepts a Lua function which works like the "customlist"
/// completion mode |:command-completion-customlist|. /// completion mode |:command-completion-customlist|. Additional parameters:
///
/// Additional parameters.
/// - desc: (string) Used for listing the command when a Lua function is used for /// - desc: (string) Used for listing the command when a Lua function is used for
/// {command}. /// {command}.
/// - force: (boolean) Override any previous definition. /// - force: (boolean, default true) Override any previous definition.
/// @param[out] err Error details, if any. /// @param[out] err Error details, if any.
void nvim_add_user_command(String name, Object command, Dict(user_command) *opts, Error *err) void nvim_add_user_command(String name, Object command, Dict(user_command) *opts, Error *err)
FUNC_API_SINCE(9) FUNC_API_SINCE(9)