mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
API: nvim_get_commands(): more attributes
Support more :command attributes: -bang -bar -register
This commit is contained in:
@@ -459,14 +459,13 @@ Integer nvim_buf_get_changedtick(Buffer buffer, Error *err)
|
||||
return buf->b_changedtick;
|
||||
}
|
||||
|
||||
/// Gets a list of dictionaries describing buffer-local mappings.
|
||||
/// The "buffer" key in the returned dictionary reflects the buffer
|
||||
/// handle where the mapping is present.
|
||||
/// Gets a list of buffer-local |mapping| definitions.
|
||||
///
|
||||
/// @param mode Mode short-name ("n", "i", "v", ...)
|
||||
/// @param buffer Buffer handle
|
||||
/// @param[out] err Error details, if any
|
||||
/// @returns Array of maparg()-like dictionaries describing mappings
|
||||
/// @returns Array of maparg()-like dictionaries describing mappings.
|
||||
/// The "buffer" key holds the associated buffer handle.
|
||||
ArrayOf(Dictionary) nvim_buf_get_keymap(Buffer buffer, String mode, Error *err)
|
||||
FUNC_API_SINCE(3)
|
||||
{
|
||||
@@ -479,7 +478,7 @@ ArrayOf(Dictionary) nvim_buf_get_keymap(Buffer buffer, String mode, Error *err)
|
||||
return keymap_array(mode, buf);
|
||||
}
|
||||
|
||||
/// Gets a list of maps describing buffer-local |user-commands|.
|
||||
/// Gets a list of buffer-local |user-commands|.
|
||||
///
|
||||
/// @param buffer Buffer handle.
|
||||
/// @param opts Optional parameters. Currently only supports
|
||||
|
@@ -948,18 +948,20 @@ Dictionary nvim_get_mode(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Gets a list of dictionaries describing global (non-buffer) mappings.
|
||||
/// The "buffer" key in the returned dictionary is always zero.
|
||||
/// Gets a list of global (non-buffer-local) |mapping| definitions.
|
||||
///
|
||||
/// @param mode Mode short-name ("n", "i", "v", ...)
|
||||
/// @returns Array of maparg()-like dictionaries describing mappings
|
||||
/// @returns Array of maparg()-like dictionaries describing mappings.
|
||||
/// The "buffer" key is always zero.
|
||||
ArrayOf(Dictionary) nvim_get_keymap(String mode)
|
||||
FUNC_API_SINCE(3)
|
||||
{
|
||||
return keymap_array(mode, NULL);
|
||||
}
|
||||
|
||||
/// Gets a list of maps describing global |user-commands|.
|
||||
/// Gets a list of global (non-buffer-local) Ex commands.
|
||||
///
|
||||
/// Currently only |user-commands| are supported, not builtin Ex commands.
|
||||
///
|
||||
/// @param opts Optional parameters. Currently only supports
|
||||
/// {"builtin":false}
|
||||
|
@@ -9990,14 +9990,16 @@ ArrayOf(Dictionary) commands_array(buf_T *buf)
|
||||
PUT(d, "name", STRING_OBJ(cstr_to_string((char *)cmd->uc_name)));
|
||||
PUT(d, "definition", STRING_OBJ(cstr_to_string((char *)cmd->uc_rep)));
|
||||
PUT(d, "script_id", INTEGER_OBJ(cmd->uc_scriptID));
|
||||
PUT(d, "bang", BOOLEAN_OBJ(!!(cmd->uc_argt & BANG)));
|
||||
PUT(d, "bar", BOOLEAN_OBJ(!!(cmd->uc_argt & TRLBAR)));
|
||||
PUT(d, "register", BOOLEAN_OBJ(!!(cmd->uc_argt & REGSTR)));
|
||||
|
||||
// "nargs" key
|
||||
switch (cmd->uc_argt & (EXTRA|NOSPC|NEEDARG)) {
|
||||
case 0: arg[0] = '0'; break;
|
||||
case(EXTRA): arg[0] = '*'; break;
|
||||
case(EXTRA|NOSPC): arg[0] = '?'; break;
|
||||
case(EXTRA|NEEDARG): arg[0] = '+'; break;
|
||||
case(EXTRA|NOSPC|NEEDARG): arg[0] = '1'; break;
|
||||
case 0: arg[0] = '0'; break;
|
||||
case(EXTRA): arg[0] = '*'; break;
|
||||
case(EXTRA|NOSPC): arg[0] = '?'; break;
|
||||
case(EXTRA|NEEDARG): arg[0] = '+'; break;
|
||||
case(EXTRA|NOSPC|NEEDARG): arg[0] = '1'; break;
|
||||
}
|
||||
PUT(d, "nargs", STRING_OBJ(cstr_to_string(arg)));
|
||||
|
||||
|
Reference in New Issue
Block a user