aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-05-11 21:26:05 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-05-12 07:29:21 +0200
commit137eedb4edab1643b47282cce4ca07dd2ee42a63 (patch)
tree75063f22b1a90605b6f2aee0233729eaf06306b4 /src
parentcb6672853a0df3dbe5202621d818ef1c2da7432c (diff)
downloadrneovim-137eedb4edab1643b47282cce4ca07dd2ee42a63.tar.gz
rneovim-137eedb4edab1643b47282cce4ca07dd2ee42a63.tar.bz2
rneovim-137eedb4edab1643b47282cce4ca07dd2ee42a63.zip
API: nvim_get_commands(): return Dictionary
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c17
-rw-r--r--src/nvim/api/vim.c10
-rw-r--r--src/nvim/ex_docmd.c14
3 files changed, 20 insertions, 21 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index eda7fcd74c..fa4ad27e60 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -467,7 +467,7 @@ Integer nvim_buf_get_changedtick(Buffer buffer, Error *err)
/// @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)
+ FUNC_API_SINCE(3)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@@ -478,16 +478,15 @@ ArrayOf(Dictionary) nvim_buf_get_keymap(Buffer buffer, String mode, Error *err)
return keymap_array(mode, buf);
}
-/// Gets a list of buffer-local |user-commands|.
+/// Gets a map of buffer-local |user-commands|.
///
/// @param buffer Buffer handle.
/// @param opts Optional parameters. Currently not used.
/// @param[out] err Error details, if any.
///
-/// @returns Array of dictionaries describing commands.
-ArrayOf(Dictionary) nvim_buf_get_commands(Buffer buffer, Dictionary opts,
- Error *err)
- FUNC_API_SINCE(4)
+/// @returns Map of maps describing commands.
+Dictionary nvim_buf_get_commands(Buffer buffer, Dictionary opts, Error *err)
+ FUNC_API_SINCE(4)
{
bool global = (buffer == -1);
bool builtin = false;
@@ -497,7 +496,7 @@ ArrayOf(Dictionary) nvim_buf_get_commands(Buffer buffer, Dictionary opts,
Object v = opts.items[i].value;
if (!strequal("builtin", k.data)) {
api_set_error(err, kErrorTypeValidation, "unexpected key: %s", k.data);
- return (Array)ARRAY_DICT_INIT;
+ return (Dictionary)ARRAY_DICT_INIT;
}
if (strequal("builtin", k.data)) {
builtin = v.data.boolean;
@@ -507,14 +506,14 @@ ArrayOf(Dictionary) nvim_buf_get_commands(Buffer buffer, Dictionary opts,
if (global) {
if (builtin) {
api_set_error(err, kErrorTypeValidation, "builtin=true not implemented");
- return (Array)ARRAY_DICT_INIT;
+ return (Dictionary)ARRAY_DICT_INIT;
}
return commands_array(NULL);
}
buf_T *buf = find_buffer_by_handle(buffer, err);
if (builtin || !buf) {
- return (Array)ARRAY_DICT_INIT;
+ return (Dictionary)ARRAY_DICT_INIT;
}
return commands_array(buf);
}
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 305cc1a43c..7a951d4e67 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -954,12 +954,12 @@ Dictionary nvim_get_mode(void)
/// @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)
+ FUNC_API_SINCE(3)
{
return keymap_array(mode, NULL);
}
-/// Gets a list of global (non-buffer-local) Ex commands.
+/// Gets a map of global (non-buffer-local) Ex commands.
///
/// Currently only |user-commands| are supported, not builtin Ex commands.
///
@@ -967,9 +967,9 @@ ArrayOf(Dictionary) nvim_get_keymap(String mode)
/// {"builtin":false}
/// @param[out] err Error details, if any.
///
-/// @returns Array of dictionaries describing commands.
-ArrayOf(Dictionary) nvim_get_commands(Dictionary opts, Error *err)
- FUNC_API_SINCE(4)
+/// @returns Map of maps describing commands.
+Dictionary nvim_get_commands(Dictionary opts, Error *err)
+ FUNC_API_SINCE(4)
{
return nvim_buf_get_commands(-1, opts, err);
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index e92dbc4cc8..52b810085c 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9969,15 +9969,15 @@ bool cmd_can_preview(char_u *cmd)
return false;
}
-/// Gets a list of maps describing user-commands defined for buffer `buf`
-/// or defined globally if `buf` is NULL.
+/// Gets a map of maps describing user-commands defined for buffer `buf` or
+/// defined globally if `buf` is NULL.
///
-/// @param buf Buffer to inspect, or NULL to get global user-commands.
+/// @param buf Buffer to inspect, or NULL to get global commands.
///
-/// @return Array of dictionaries describing commands
-ArrayOf(Dictionary) commands_array(buf_T *buf)
+/// @return Map of maps describing commands
+Dictionary commands_array(buf_T *buf)
{
- Array rv = ARRAY_DICT_INIT;
+ Dictionary rv = ARRAY_DICT_INIT;
Object obj = NIL;
char str[10];
garray_T *gap = (buf == NULL) ? &ucmds : &buf->b_ucmds;
@@ -10043,7 +10043,7 @@ ArrayOf(Dictionary) commands_array(buf_T *buf)
}
PUT(d, "addr", obj);
- ADD(rv, DICTIONARY_OBJ(d));
+ PUT(rv, (char *)cmd->uc_name, DICTIONARY_OBJ(d));
}
return rv;
}