viml: introduce menu_get() function #6322

menu_get({path}, {modes}). See :h menu_get.
This commit is contained in:
Matthieu Coudron
2017-03-21 03:21:53 +01:00
committed by Justin M. Keyes
parent e6d54407ba
commit dc685387a3
9 changed files with 629 additions and 132 deletions

View File

@@ -47,6 +47,7 @@
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/keymap.h"
@@ -8173,6 +8174,19 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
/// "menu_get(path [, modes])" function
static void f_menu_get(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
tv_list_alloc_ret(rettv);
int modes = MENU_ALL_MODES;
if (argvars[1].v_type == VAR_STRING) {
const char_u *const strmodes = (char_u *)tv_get_string(&argvars[1]);
modes = get_menu_cmd_modes(strmodes, false, NULL, NULL);
}
menu_get((char_u *)tv_get_string(&argvars[0]), modes, rettv->vval.v_list);
}
/*
* "extend(list, list [, idx])" function
* "extend(dict, dict [, action])" function