mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
eval: Move VimL functions list to a lua file
Removes all kinds of problems with sorting, provides a ready-to-use function list representation for genvimvim.lua, does not require specifying function name twice (VimL function name (string) + f_ function name).
This commit is contained in:
parent
0ade1bb706
commit
8fb7273ac0
42
scripts/geneval.lua
Normal file
42
scripts/geneval.lua
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
local nvimsrcdir = arg[1]
|
||||||
|
local autodir = arg[2]
|
||||||
|
|
||||||
|
if nvimsrcdir == '--help' then
|
||||||
|
print([[
|
||||||
|
Usage:
|
||||||
|
lua geneval.lua src/nvim build/src/nvim/auto
|
||||||
|
|
||||||
|
Will generate build/src/nvim/auto/funcs.generated.h with definition of functions
|
||||||
|
static const array.
|
||||||
|
]])
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
package.path = nvimsrcdir .. '/?.lua;' .. package.path
|
||||||
|
|
||||||
|
local funcsfname = autodir .. '/funcs.generated.h'
|
||||||
|
local funcsfile = io.open(funcsfname, 'w')
|
||||||
|
|
||||||
|
local funcs = require('eval')
|
||||||
|
|
||||||
|
local sorted_funcs = {}
|
||||||
|
for name, def in pairs(funcs.funcs) do
|
||||||
|
def.name = name
|
||||||
|
def.args = def.args or 0
|
||||||
|
if type(def.args) == 'number' then
|
||||||
|
def.args = {def.args, def.args}
|
||||||
|
elseif #def.args == 1 then
|
||||||
|
def.args[2] = 'MAX_FUNC_ARGS'
|
||||||
|
end
|
||||||
|
def.func = def.func or ('f_' .. def.name)
|
||||||
|
sorted_funcs[#sorted_funcs + 1] = def
|
||||||
|
end
|
||||||
|
table.sort(sorted_funcs, function(a, b) return a.name < b.name end)
|
||||||
|
|
||||||
|
funcsfile:write('static const VimLFuncDef functions[] = {\n')
|
||||||
|
for _, def in ipairs(sorted_funcs) do
|
||||||
|
funcsfile:write((' { "%s", %s, %s, &%s },\n'):format(
|
||||||
|
def.name, def.args[1], def.args[2], def.func
|
||||||
|
))
|
||||||
|
end
|
||||||
|
funcsfile:write('};\n')
|
@ -23,6 +23,7 @@ end
|
|||||||
local options = require('options')
|
local options = require('options')
|
||||||
local auevents = require('auevents')
|
local auevents = require('auevents')
|
||||||
local ex_cmds = require('ex_cmds')
|
local ex_cmds = require('ex_cmds')
|
||||||
|
local eval = require('eval')
|
||||||
|
|
||||||
local cmd_kw = function(prev_cmd, cmd)
|
local cmd_kw = function(prev_cmd, cmd)
|
||||||
if not prev_cmd then
|
if not prev_cmd then
|
||||||
@ -113,23 +114,12 @@ local vimfun_start = 'syn keyword vimFuncName contained '
|
|||||||
w('\n\n' .. vimfun_start)
|
w('\n\n' .. vimfun_start)
|
||||||
eval_fd = io.open(nvimsrcdir .. '/eval.c', 'r')
|
eval_fd = io.open(nvimsrcdir .. '/eval.c', 'r')
|
||||||
local started = 0
|
local started = 0
|
||||||
for line in eval_fd:lines() do
|
for name, def in pairs(eval.funcs) do
|
||||||
if line == '} functions[] =' then
|
if name then
|
||||||
started = 1
|
if lld.line_length > 850 then
|
||||||
elseif started == 1 then
|
w('\n' .. vimfun_start)
|
||||||
assert (line == '{')
|
|
||||||
started = 2
|
|
||||||
elseif started == 2 then
|
|
||||||
if line == '};' then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
local func_name = line:match('^ { "([%w_]+)",')
|
|
||||||
if func_name then
|
|
||||||
if lld.line_length > 850 then
|
|
||||||
w('\n' .. vimfun_start)
|
|
||||||
end
|
|
||||||
w(' ' .. func_name)
|
|
||||||
end
|
end
|
||||||
|
w(' ' .. name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eval_fd:close()
|
eval_fd:close()
|
||||||
|
@ -19,14 +19,17 @@ set(HEADER_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gendeclarations.lua)
|
|||||||
set(GENERATED_INCLUDES_DIR ${PROJECT_BINARY_DIR}/include)
|
set(GENERATED_INCLUDES_DIR ${PROJECT_BINARY_DIR}/include)
|
||||||
set(GENERATED_EX_CMDS_ENUM ${GENERATED_INCLUDES_DIR}/ex_cmds_enum.generated.h)
|
set(GENERATED_EX_CMDS_ENUM ${GENERATED_INCLUDES_DIR}/ex_cmds_enum.generated.h)
|
||||||
set(GENERATED_EX_CMDS_DEFS ${GENERATED_DIR}/ex_cmds_defs.generated.h)
|
set(GENERATED_EX_CMDS_DEFS ${GENERATED_DIR}/ex_cmds_defs.generated.h)
|
||||||
|
set(GENERATED_FUNCS ${GENERATED_DIR}/funcs.generated.h)
|
||||||
set(GENERATED_EVENTS_ENUM ${GENERATED_INCLUDES_DIR}/auevents_enum.generated.h)
|
set(GENERATED_EVENTS_ENUM ${GENERATED_INCLUDES_DIR}/auevents_enum.generated.h)
|
||||||
set(GENERATED_EVENTS_NAMES_MAP ${GENERATED_DIR}/auevents_name_map.generated.h)
|
set(GENERATED_EVENTS_NAMES_MAP ${GENERATED_DIR}/auevents_name_map.generated.h)
|
||||||
set(GENERATED_OPTIONS ${GENERATED_DIR}/options.generated.h)
|
set(GENERATED_OPTIONS ${GENERATED_DIR}/options.generated.h)
|
||||||
set(EX_CMDS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genex_cmds.lua)
|
set(EX_CMDS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genex_cmds.lua)
|
||||||
|
set(FUNCS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/geneval.lua)
|
||||||
set(EVENTS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gen_events.lua)
|
set(EVENTS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gen_events.lua)
|
||||||
set(OPTIONS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genoptions.lua)
|
set(OPTIONS_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genoptions.lua)
|
||||||
set(EVENTS_LIST_FILE ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua)
|
set(EVENTS_LIST_FILE ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua)
|
||||||
set(EX_CMDS_DEFS_FILE ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua)
|
set(EX_CMDS_DEFS_FILE ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua)
|
||||||
|
set(EVAL_DEFS_FILE ${PROJECT_SOURCE_DIR}/src/nvim/eval.lua)
|
||||||
set(OPTIONS_LIST_FILE ${PROJECT_SOURCE_DIR}/src/nvim/options.lua)
|
set(OPTIONS_LIST_FILE ${PROJECT_SOURCE_DIR}/src/nvim/options.lua)
|
||||||
set(UNICODE_TABLES_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genunicodetables.lua)
|
set(UNICODE_TABLES_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genunicodetables.lua)
|
||||||
set(UNICODE_DIR ${PROJECT_SOURCE_DIR}/unicode)
|
set(UNICODE_DIR ${PROJECT_SOURCE_DIR}/unicode)
|
||||||
@ -200,6 +203,7 @@ list(APPEND NEOVIM_GENERATED_SOURCES
|
|||||||
"${GENERATED_EVENTS_NAMES_MAP}"
|
"${GENERATED_EVENTS_NAMES_MAP}"
|
||||||
"${GENERATED_OPTIONS}"
|
"${GENERATED_OPTIONS}"
|
||||||
"${GENERATED_UNICODE_TABLES}"
|
"${GENERATED_UNICODE_TABLES}"
|
||||||
|
"${GENERATED_FUNCS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
||||||
@ -208,6 +212,12 @@ add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
|||||||
DEPENDS ${EX_CMDS_GENERATOR} ${EX_CMDS_DEFS_FILE}
|
DEPENDS ${EX_CMDS_GENERATOR} ${EX_CMDS_DEFS_FILE}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT ${GENERATED_FUNCS}
|
||||||
|
COMMAND ${LUA_PRG} ${FUNCS_GENERATOR}
|
||||||
|
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_DIR}
|
||||||
|
DEPENDS ${FUNCS_GENERATOR} ${EVAL_DEFS_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
add_custom_command(OUTPUT ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
||||||
COMMAND ${LUA_PRG} ${EVENTS_GENERATOR}
|
COMMAND ${LUA_PRG} ${EVENTS_GENERATOR}
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
||||||
|
339
src/nvim/eval.c
339
src/nvim/eval.c
@ -6681,331 +6681,20 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Prototype of C function that implements VimL function
|
||||||
* Array with names and number of arguments of all internal functions
|
typedef void (*VimLFunc)(typval_T *args, typval_T *rvar);
|
||||||
* MUST BE KEPT SORTED IN strcmp() ORDER FOR BINARY SEARCH!
|
|
||||||
*/
|
/// Structure holding VimL function definition
|
||||||
static struct fst {
|
typedef struct fst {
|
||||||
char *f_name; /* function name */
|
char *f_name; ///< Function name.
|
||||||
char f_min_argc; /* minimal number of arguments */
|
uint8_t f_min_argc; ///< Minimal number of arguments.
|
||||||
char f_max_argc; /* maximal number of arguments */
|
uint8_t f_max_argc; ///< Maximal number of arguments.
|
||||||
void (*f_func)(typval_T *args, typval_T *rvar);
|
VimLFunc f_func; ///< Function implementation.
|
||||||
/* implementation of function */
|
} VimLFuncDef;
|
||||||
} functions[] =
|
|
||||||
{
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
{ "abs", 1, 1, f_abs },
|
# include "funcs.generated.h"
|
||||||
{ "acos", 1, 1, f_acos }, // WJMc
|
#endif
|
||||||
{ "add", 2, 2, f_add },
|
|
||||||
{ "and", 2, 2, f_and },
|
|
||||||
{ "api_info", 0, 0, f_api_info },
|
|
||||||
{ "append", 2, 2, f_append },
|
|
||||||
{ "argc", 0, 0, f_argc },
|
|
||||||
{ "argidx", 0, 0, f_argidx },
|
|
||||||
{ "arglistid", 0, 2, f_arglistid },
|
|
||||||
{ "argv", 0, 1, f_argv },
|
|
||||||
{ "asin", 1, 1, f_asin }, // WJMc
|
|
||||||
{ "assert_equal", 2, 3, f_assert_equal },
|
|
||||||
{ "assert_exception", 1, 2, f_assert_exception },
|
|
||||||
{ "assert_fails", 1, 2, f_assert_fails },
|
|
||||||
{ "assert_false", 1, 2, f_assert_false },
|
|
||||||
{ "assert_match", 2, 3, f_assert_match },
|
|
||||||
{ "assert_notequal", 2, 3, f_assert_notequal },
|
|
||||||
{ "assert_notmatch", 2, 3, f_assert_notmatch },
|
|
||||||
{ "assert_true", 1, 2, f_assert_true },
|
|
||||||
{ "atan", 1, 1, f_atan },
|
|
||||||
{ "atan2", 2, 2, f_atan2 },
|
|
||||||
{ "browse", 4, 4, f_browse },
|
|
||||||
{ "browsedir", 2, 2, f_browsedir },
|
|
||||||
{ "bufexists", 1, 1, f_bufexists },
|
|
||||||
{ "buffer_exists", 1, 1, f_bufexists }, // obsolete
|
|
||||||
{ "buffer_name", 1, 1, f_bufname }, // obsolete
|
|
||||||
{ "buffer_number", 1, 1, f_bufnr }, // obsolete
|
|
||||||
{ "buflisted", 1, 1, f_buflisted },
|
|
||||||
{ "bufloaded", 1, 1, f_bufloaded },
|
|
||||||
{ "bufname", 1, 1, f_bufname },
|
|
||||||
{ "bufnr", 1, 2, f_bufnr },
|
|
||||||
{ "bufwinnr", 1, 1, f_bufwinnr },
|
|
||||||
{ "byte2line", 1, 1, f_byte2line },
|
|
||||||
{ "byteidx", 2, 2, f_byteidx },
|
|
||||||
{ "byteidxcomp", 2, 2, f_byteidxcomp },
|
|
||||||
{ "call", 2, 3, f_call },
|
|
||||||
{ "ceil", 1, 1, f_ceil },
|
|
||||||
{ "changenr", 0, 0, f_changenr },
|
|
||||||
{ "char2nr", 1, 2, f_char2nr },
|
|
||||||
{ "cindent", 1, 1, f_cindent },
|
|
||||||
{ "clearmatches", 0, 0, f_clearmatches },
|
|
||||||
{ "col", 1, 1, f_col },
|
|
||||||
{ "complete", 2, 2, f_complete },
|
|
||||||
{ "complete_add", 1, 1, f_complete_add },
|
|
||||||
{ "complete_check", 0, 0, f_complete_check },
|
|
||||||
{ "confirm", 1, 4, f_confirm },
|
|
||||||
{ "copy", 1, 1, f_copy },
|
|
||||||
{ "cos", 1, 1, f_cos },
|
|
||||||
{ "cosh", 1, 1, f_cosh },
|
|
||||||
{ "count", 2, 4, f_count },
|
|
||||||
{ "cscope_connection", 0, 3, f_cscope_connection },
|
|
||||||
{ "cursor", 1, 3, f_cursor },
|
|
||||||
{ "deepcopy", 1, 2, f_deepcopy },
|
|
||||||
{ "delete", 1, 2, f_delete },
|
|
||||||
{ "dictwatcheradd", 3, 3, f_dictwatcheradd },
|
|
||||||
{ "dictwatcherdel", 3, 3, f_dictwatcherdel },
|
|
||||||
{ "did_filetype", 0, 0, f_did_filetype },
|
|
||||||
{ "diff_filler", 1, 1, f_diff_filler },
|
|
||||||
{ "diff_hlID", 2, 2, f_diff_hlID },
|
|
||||||
{ "empty", 1, 1, f_empty },
|
|
||||||
{ "escape", 2, 2, f_escape },
|
|
||||||
{ "eval", 1, 1, f_eval },
|
|
||||||
{ "eventhandler", 0, 0, f_eventhandler },
|
|
||||||
{ "executable", 1, 1, f_executable },
|
|
||||||
{ "execute", 1, 1, f_execute },
|
|
||||||
{ "exepath", 1, 1, f_exepath },
|
|
||||||
{ "exists", 1, 1, f_exists },
|
|
||||||
{ "exp", 1, 1, f_exp },
|
|
||||||
{ "expand", 1, 3, f_expand },
|
|
||||||
{ "extend", 2, 3, f_extend },
|
|
||||||
{ "feedkeys", 1, 2, f_feedkeys },
|
|
||||||
{ "file_readable", 1, 1, f_filereadable }, // obsolete
|
|
||||||
{ "filereadable", 1, 1, f_filereadable },
|
|
||||||
{ "filewritable", 1, 1, f_filewritable },
|
|
||||||
{ "filter", 2, 2, f_filter },
|
|
||||||
{ "finddir", 1, 3, f_finddir },
|
|
||||||
{ "findfile", 1, 3, f_findfile },
|
|
||||||
{ "float2nr", 1, 1, f_float2nr },
|
|
||||||
{ "floor", 1, 1, f_floor },
|
|
||||||
{ "fmod", 2, 2, f_fmod },
|
|
||||||
{ "fnameescape", 1, 1, f_fnameescape },
|
|
||||||
{ "fnamemodify", 2, 2, f_fnamemodify },
|
|
||||||
{ "foldclosed", 1, 1, f_foldclosed },
|
|
||||||
{ "foldclosedend", 1, 1, f_foldclosedend },
|
|
||||||
{ "foldlevel", 1, 1, f_foldlevel },
|
|
||||||
{ "foldtext", 0, 0, f_foldtext },
|
|
||||||
{ "foldtextresult", 1, 1, f_foldtextresult },
|
|
||||||
{ "foreground", 0, 0, f_foreground },
|
|
||||||
{ "function", 1, 1, f_function },
|
|
||||||
{ "garbagecollect", 0, 1, f_garbagecollect },
|
|
||||||
{ "get", 2, 3, f_get },
|
|
||||||
{ "getbufline", 2, 3, f_getbufline },
|
|
||||||
{ "getbufvar", 2, 3, f_getbufvar },
|
|
||||||
{ "getchar", 0, 1, f_getchar },
|
|
||||||
{ "getcharmod", 0, 0, f_getcharmod },
|
|
||||||
{ "getcharsearch", 0, 0, f_getcharsearch },
|
|
||||||
{ "getcmdline", 0, 0, f_getcmdline },
|
|
||||||
{ "getcmdpos", 0, 0, f_getcmdpos },
|
|
||||||
{ "getcmdtype", 0, 0, f_getcmdtype },
|
|
||||||
{ "getcmdwintype", 0, 0, f_getcmdwintype },
|
|
||||||
{ "getcompletion", 2, 2, f_getcompletion },
|
|
||||||
{ "getcurpos", 0, 0, f_getcurpos },
|
|
||||||
{ "getcwd", 0, 2, f_getcwd },
|
|
||||||
{ "getfontname", 0, 1, f_getfontname },
|
|
||||||
{ "getfperm", 1, 1, f_getfperm },
|
|
||||||
{ "getfsize", 1, 1, f_getfsize },
|
|
||||||
{ "getftime", 1, 1, f_getftime },
|
|
||||||
{ "getftype", 1, 1, f_getftype },
|
|
||||||
{ "getline", 1, 2, f_getline },
|
|
||||||
{ "getloclist", 1, 1, f_getqflist },
|
|
||||||
{ "getmatches", 0, 0, f_getmatches },
|
|
||||||
{ "getpid", 0, 0, f_getpid },
|
|
||||||
{ "getpos", 1, 1, f_getpos },
|
|
||||||
{ "getqflist", 0, 0, f_getqflist },
|
|
||||||
{ "getreg", 0, 3, f_getreg },
|
|
||||||
{ "getregtype", 0, 1, f_getregtype },
|
|
||||||
{ "gettabvar", 2, 3, f_gettabvar },
|
|
||||||
{ "gettabwinvar", 3, 4, f_gettabwinvar },
|
|
||||||
{ "getwinposx", 0, 0, f_getwinposx },
|
|
||||||
{ "getwinposy", 0, 0, f_getwinposy },
|
|
||||||
{ "getwinvar", 2, 3, f_getwinvar },
|
|
||||||
{ "glob", 1, 4, f_glob },
|
|
||||||
{ "glob2regpat", 1, 1, f_glob2regpat },
|
|
||||||
{ "globpath", 2, 5, f_globpath },
|
|
||||||
{ "has", 1, 1, f_has },
|
|
||||||
{ "has_key", 2, 2, f_has_key },
|
|
||||||
{ "haslocaldir", 0, 2, f_haslocaldir },
|
|
||||||
{ "hasmapto", 1, 3, f_hasmapto },
|
|
||||||
{ "highlightID", 1, 1, f_hlID }, // obsolete
|
|
||||||
{ "highlight_exists", 1, 1, f_hlexists }, // obsolete
|
|
||||||
{ "histadd", 2, 2, f_histadd },
|
|
||||||
{ "histdel", 1, 2, f_histdel },
|
|
||||||
{ "histget", 1, 2, f_histget },
|
|
||||||
{ "histnr", 1, 1, f_histnr },
|
|
||||||
{ "hlID", 1, 1, f_hlID },
|
|
||||||
{ "hlexists", 1, 1, f_hlexists },
|
|
||||||
{ "hostname", 0, 0, f_hostname },
|
|
||||||
{ "iconv", 3, 3, f_iconv },
|
|
||||||
{ "indent", 1, 1, f_indent },
|
|
||||||
{ "index", 2, 4, f_index },
|
|
||||||
{ "input", 1, 3, f_input },
|
|
||||||
{ "inputdialog", 1, 3, f_inputdialog },
|
|
||||||
{ "inputlist", 1, 1, f_inputlist },
|
|
||||||
{ "inputrestore", 0, 0, f_inputrestore },
|
|
||||||
{ "inputsave", 0, 0, f_inputsave },
|
|
||||||
{ "inputsecret", 1, 2, f_inputsecret },
|
|
||||||
{ "insert", 2, 3, f_insert },
|
|
||||||
{ "invert", 1, 1, f_invert },
|
|
||||||
{ "isdirectory", 1, 1, f_isdirectory },
|
|
||||||
{ "islocked", 1, 1, f_islocked },
|
|
||||||
{ "items", 1, 1, f_items },
|
|
||||||
{ "jobclose", 1, 2, f_jobclose },
|
|
||||||
{ "jobpid", 1, 1, f_jobpid },
|
|
||||||
{ "jobresize", 3, 3, f_jobresize },
|
|
||||||
{ "jobsend", 2, 2, f_jobsend },
|
|
||||||
{ "jobstart", 1, 2, f_jobstart },
|
|
||||||
{ "jobstop", 1, 1, f_jobstop },
|
|
||||||
{ "jobwait", 1, 2, f_jobwait },
|
|
||||||
{ "join", 1, 2, f_join },
|
|
||||||
{ "json_decode", 1, 1, f_json_decode },
|
|
||||||
{ "json_encode", 1, 1, f_json_encode },
|
|
||||||
{ "keys", 1, 1, f_keys },
|
|
||||||
{ "last_buffer_nr", 0, 0, f_last_buffer_nr }, // obsolete
|
|
||||||
{ "len", 1, 1, f_len },
|
|
||||||
{ "libcall", 3, 3, f_libcall },
|
|
||||||
{ "libcallnr", 3, 3, f_libcallnr },
|
|
||||||
{ "line", 1, 1, f_line },
|
|
||||||
{ "line2byte", 1, 1, f_line2byte },
|
|
||||||
{ "lispindent", 1, 1, f_lispindent },
|
|
||||||
{ "localtime", 0, 0, f_localtime },
|
|
||||||
{ "log", 1, 1, f_log },
|
|
||||||
{ "log10", 1, 1, f_log10 },
|
|
||||||
{ "map", 2, 2, f_map },
|
|
||||||
{ "maparg", 1, 4, f_maparg },
|
|
||||||
{ "mapcheck", 1, 3, f_mapcheck },
|
|
||||||
{ "match", 2, 4, f_match },
|
|
||||||
{ "matchadd", 2, 5, f_matchadd },
|
|
||||||
{ "matchaddpos", 2, 5, f_matchaddpos },
|
|
||||||
{ "matcharg", 1, 1, f_matcharg },
|
|
||||||
{ "matchdelete", 1, 1, f_matchdelete },
|
|
||||||
{ "matchend", 2, 4, f_matchend },
|
|
||||||
{ "matchlist", 2, 4, f_matchlist },
|
|
||||||
{ "matchstr", 2, 4, f_matchstr },
|
|
||||||
{ "max", 1, 1, f_max },
|
|
||||||
{ "min", 1, 1, f_min },
|
|
||||||
{ "mkdir", 1, 3, f_mkdir },
|
|
||||||
{ "mode", 0, 1, f_mode },
|
|
||||||
{ "msgpackdump", 1, 1, f_msgpackdump },
|
|
||||||
{ "msgpackparse", 1, 1, f_msgpackparse },
|
|
||||||
{ "nextnonblank", 1, 1, f_nextnonblank },
|
|
||||||
{ "nr2char", 1, 2, f_nr2char },
|
|
||||||
{ "or", 2, 2, f_or },
|
|
||||||
{ "pathshorten", 1, 1, f_pathshorten },
|
|
||||||
{ "pow", 2, 2, f_pow },
|
|
||||||
{ "prevnonblank", 1, 1, f_prevnonblank },
|
|
||||||
{ "printf", 2, MAX_FUNC_ARGS, f_printf },
|
|
||||||
{ "pumvisible", 0, 0, f_pumvisible },
|
|
||||||
{ "py3eval", 1, 1, f_py3eval },
|
|
||||||
{ "pyeval", 1, 1, f_pyeval },
|
|
||||||
{ "range", 1, 3, f_range },
|
|
||||||
{ "readfile", 1, 3, f_readfile },
|
|
||||||
{ "reltime", 0, 2, f_reltime },
|
|
||||||
{ "reltimefloat", 1, 1, f_reltimefloat },
|
|
||||||
{ "reltimestr", 1, 1, f_reltimestr },
|
|
||||||
{ "remove", 2, 3, f_remove },
|
|
||||||
{ "rename", 2, 2, f_rename },
|
|
||||||
{ "repeat", 2, 2, f_repeat },
|
|
||||||
{ "resolve", 1, 1, f_resolve },
|
|
||||||
{ "reverse", 1, 1, f_reverse },
|
|
||||||
{ "round", 1, 1, f_round },
|
|
||||||
{ "rpcnotify", 2, MAX_FUNC_ARGS, f_rpcnotify },
|
|
||||||
{ "rpcrequest", 2, MAX_FUNC_ARGS, f_rpcrequest },
|
|
||||||
{ "rpcstart", 1, 2, f_rpcstart },
|
|
||||||
{ "rpcstop", 1, 1, f_rpcstop },
|
|
||||||
{ "screenattr", 2, 2, f_screenattr },
|
|
||||||
{ "screenchar", 2, 2, f_screenchar },
|
|
||||||
{ "screencol", 0, 0, f_screencol },
|
|
||||||
{ "screenrow", 0, 0, f_screenrow },
|
|
||||||
{ "search", 1, 4, f_search },
|
|
||||||
{ "searchdecl", 1, 3, f_searchdecl },
|
|
||||||
{ "searchpair", 3, 7, f_searchpair },
|
|
||||||
{ "searchpairpos", 3, 7, f_searchpairpos },
|
|
||||||
{ "searchpos", 1, 4, f_searchpos },
|
|
||||||
{ "serverlist", 0, 0, f_serverlist },
|
|
||||||
{ "serverstart", 0, 1, f_serverstart },
|
|
||||||
{ "serverstop", 1, 1, f_serverstop },
|
|
||||||
{ "setbufvar", 3, 3, f_setbufvar },
|
|
||||||
{ "setcharsearch", 1, 1, f_setcharsearch },
|
|
||||||
{ "setcmdpos", 1, 1, f_setcmdpos },
|
|
||||||
{ "setfperm", 2, 2, f_setfperm },
|
|
||||||
{ "setline", 2, 2, f_setline },
|
|
||||||
{ "setloclist", 2, 4, f_setloclist },
|
|
||||||
{ "setmatches", 1, 1, f_setmatches },
|
|
||||||
{ "setpos", 2, 2, f_setpos },
|
|
||||||
{ "setqflist", 1, 3, f_setqflist },
|
|
||||||
{ "setreg", 2, 3, f_setreg },
|
|
||||||
{ "settabvar", 3, 3, f_settabvar },
|
|
||||||
{ "settabwinvar", 4, 4, f_settabwinvar },
|
|
||||||
{ "setwinvar", 3, 3, f_setwinvar },
|
|
||||||
{ "sha256", 1, 1, f_sha256 },
|
|
||||||
{ "shellescape", 1, 2, f_shellescape },
|
|
||||||
{ "shiftwidth", 0, 0, f_shiftwidth },
|
|
||||||
{ "simplify", 1, 1, f_simplify },
|
|
||||||
{ "sin", 1, 1, f_sin },
|
|
||||||
{ "sinh", 1, 1, f_sinh },
|
|
||||||
{ "sort", 1, 3, f_sort },
|
|
||||||
{ "soundfold", 1, 1, f_soundfold },
|
|
||||||
{ "spellbadword", 0, 1, f_spellbadword },
|
|
||||||
{ "spellsuggest", 1, 3, f_spellsuggest },
|
|
||||||
{ "split", 1, 3, f_split },
|
|
||||||
{ "sqrt", 1, 1, f_sqrt },
|
|
||||||
{ "str2float", 1, 1, f_str2float },
|
|
||||||
{ "str2nr", 1, 2, f_str2nr },
|
|
||||||
{ "strchars", 1, 2, f_strchars },
|
|
||||||
{ "strdisplaywidth", 1, 2, f_strdisplaywidth },
|
|
||||||
{ "strftime", 1, 2, f_strftime },
|
|
||||||
{ "stridx", 2, 3, f_stridx },
|
|
||||||
{ "string", 1, 1, f_string },
|
|
||||||
{ "strlen", 1, 1, f_strlen },
|
|
||||||
{ "strpart", 2, 3, f_strpart },
|
|
||||||
{ "strridx", 2, 3, f_strridx },
|
|
||||||
{ "strtrans", 1, 1, f_strtrans },
|
|
||||||
{ "strwidth", 1, 1, f_strwidth },
|
|
||||||
{ "submatch", 1, 2, f_submatch },
|
|
||||||
{ "substitute", 4, 4, f_substitute },
|
|
||||||
{ "synID", 3, 3, f_synID },
|
|
||||||
{ "synIDattr", 2, 3, f_synIDattr },
|
|
||||||
{ "synIDtrans", 1, 1, f_synIDtrans },
|
|
||||||
{ "synconcealed", 2, 2, f_synconcealed },
|
|
||||||
{ "synstack", 2, 2, f_synstack },
|
|
||||||
{ "system", 1, 2, f_system },
|
|
||||||
{ "systemlist", 1, 3, f_systemlist },
|
|
||||||
{ "tabpagebuflist", 0, 1, f_tabpagebuflist },
|
|
||||||
{ "tabpagenr", 0, 1, f_tabpagenr },
|
|
||||||
{ "tabpagewinnr", 1, 2, f_tabpagewinnr },
|
|
||||||
{ "tagfiles", 0, 0, f_tagfiles },
|
|
||||||
{ "taglist", 1, 1, f_taglist },
|
|
||||||
{ "tan", 1, 1, f_tan },
|
|
||||||
{ "tanh", 1, 1, f_tanh },
|
|
||||||
{ "tempname", 0, 0, f_tempname },
|
|
||||||
{ "termopen", 1, 2, f_termopen },
|
|
||||||
{ "test", 1, 1, f_test },
|
|
||||||
{ "timer_start", 2, 3, f_timer_start },
|
|
||||||
{ "timer_stop", 1, 1, f_timer_stop },
|
|
||||||
{ "tolower", 1, 1, f_tolower },
|
|
||||||
{ "toupper", 1, 1, f_toupper },
|
|
||||||
{ "tr", 3, 3, f_tr },
|
|
||||||
{ "trunc", 1, 1, f_trunc },
|
|
||||||
{ "type", 1, 1, f_type },
|
|
||||||
{ "undofile", 1, 1, f_undofile },
|
|
||||||
{ "undotree", 0, 0, f_undotree },
|
|
||||||
{ "uniq", 1, 3, f_uniq },
|
|
||||||
{ "values", 1, 1, f_values },
|
|
||||||
{ "virtcol", 1, 1, f_virtcol },
|
|
||||||
{ "visualmode", 0, 1, f_visualmode },
|
|
||||||
{ "wildmenumode", 0, 0, f_wildmenumode },
|
|
||||||
{ "win_getid", 0, 2, f_win_getid },
|
|
||||||
{ "win_gotoid", 1, 1, f_win_gotoid },
|
|
||||||
{ "win_id2tabwin", 1, 1, f_win_id2tabwin },
|
|
||||||
{ "win_id2win", 1, 1, f_win_id2win },
|
|
||||||
{ "winbufnr", 1, 1, f_winbufnr },
|
|
||||||
{ "wincol", 0, 0, f_wincol },
|
|
||||||
{ "winheight", 1, 1, f_winheight },
|
|
||||||
{ "winline", 0, 0, f_winline },
|
|
||||||
{ "winnr", 0, 1, f_winnr },
|
|
||||||
{ "winrestcmd", 0, 0, f_winrestcmd },
|
|
||||||
{ "winrestview", 1, 1, f_winrestview },
|
|
||||||
{ "winsaveview", 0, 0, f_winsaveview },
|
|
||||||
{ "winwidth", 1, 1, f_winwidth },
|
|
||||||
{ "wordcount", 0, 0, f_wordcount },
|
|
||||||
{ "writefile", 2, 3, f_writefile },
|
|
||||||
{ "xor", 2, 2, f_xor },
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
307
src/nvim/eval.lua
Normal file
307
src/nvim/eval.lua
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
-- File containing table with all functions.
|
||||||
|
--
|
||||||
|
-- Keys:
|
||||||
|
--
|
||||||
|
-- args Number of arguments, list with maximum and minimum number of arguments
|
||||||
|
-- or list with a minimum number of arguments only. Defaults to zero
|
||||||
|
-- arguments.
|
||||||
|
-- func Name of the C function which implements the VimL function. Defaults to
|
||||||
|
-- `f_{funcname}`.
|
||||||
|
|
||||||
|
local varargs = function(nr)
|
||||||
|
return {nr}
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
funcs={
|
||||||
|
abs={args=1},
|
||||||
|
acos={args=1}, -- WJMc
|
||||||
|
add={args=2},
|
||||||
|
['and']={args=2},
|
||||||
|
append={args=2},
|
||||||
|
argc={},
|
||||||
|
argidx={},
|
||||||
|
arglistid={args={0, 2}},
|
||||||
|
argv={args={0, 1}},
|
||||||
|
asin={args=1}, -- WJMc
|
||||||
|
atan={args=1},
|
||||||
|
atan2={args=2},
|
||||||
|
browse={args=4},
|
||||||
|
browsedir={args=2},
|
||||||
|
bufexists={args=1},
|
||||||
|
buffer_exists={args=1, func='f_bufexists'}, -- obsolete
|
||||||
|
buffer_name={args=1, func='f_bufname'}, -- obsolete
|
||||||
|
buffer_number={args=1, func='f_bufnr'}, -- obsolete
|
||||||
|
buflisted={args=1},
|
||||||
|
bufloaded={args=1},
|
||||||
|
bufname={args=1},
|
||||||
|
bufnr={args={1, 2}},
|
||||||
|
bufwinnr={args=1},
|
||||||
|
byte2line={args=1},
|
||||||
|
byteidx={args=2},
|
||||||
|
byteidxcomp={args=2},
|
||||||
|
call={args={2, 3}},
|
||||||
|
ceil={args=1},
|
||||||
|
changenr={},
|
||||||
|
char2nr={args={1, 2}},
|
||||||
|
cindent={args=1},
|
||||||
|
clearmatches={},
|
||||||
|
col={args=1},
|
||||||
|
complete={args=2},
|
||||||
|
complete_add={args=1},
|
||||||
|
complete_check={},
|
||||||
|
confirm={args={1, 4}},
|
||||||
|
copy={args=1},
|
||||||
|
cos={args=1},
|
||||||
|
cosh={args=1},
|
||||||
|
count={args={2, 4}},
|
||||||
|
cscope_connection={args={0, 3}},
|
||||||
|
cursor={args={1, 3}},
|
||||||
|
deepcopy={args={1, 2}},
|
||||||
|
delete={args=1},
|
||||||
|
dictwatcheradd={args=3},
|
||||||
|
dictwatcherdel={args=3},
|
||||||
|
did_filetype={},
|
||||||
|
diff_filler={args=1},
|
||||||
|
diff_hlID={args=2},
|
||||||
|
empty={args=1},
|
||||||
|
escape={args=2},
|
||||||
|
eval={args=1},
|
||||||
|
eventhandler={},
|
||||||
|
executable={args=1},
|
||||||
|
exepath={args=1},
|
||||||
|
exists={args=1},
|
||||||
|
exp={args=1},
|
||||||
|
expand={args={1, 3}},
|
||||||
|
extend={args={2, 3}},
|
||||||
|
feedkeys={args={1, 2}},
|
||||||
|
file_readable={args=1, func='f_filereadable'}, -- obsolete
|
||||||
|
filereadable={args=1},
|
||||||
|
filewritable={args=1},
|
||||||
|
filter={args=2},
|
||||||
|
finddir={args={1, 3}},
|
||||||
|
findfile={args={1, 3}},
|
||||||
|
float2nr={args=1},
|
||||||
|
floor={args=1},
|
||||||
|
fmod={args=2},
|
||||||
|
fnameescape={args=1},
|
||||||
|
fnamemodify={args=2},
|
||||||
|
foldclosed={args=1},
|
||||||
|
foldclosedend={args=1},
|
||||||
|
foldlevel={args=1},
|
||||||
|
foldtext={},
|
||||||
|
foldtextresult={args=1},
|
||||||
|
foreground={},
|
||||||
|
['function']={args=1},
|
||||||
|
garbagecollect={args={0, 1}},
|
||||||
|
get={args={2, 3}},
|
||||||
|
getbufline={args={2, 3}},
|
||||||
|
getbufvar={args={2, 3}},
|
||||||
|
getchar={args={0, 1}},
|
||||||
|
getcharmod={},
|
||||||
|
getcharsearch={},
|
||||||
|
getcmdline={},
|
||||||
|
getcmdpos={},
|
||||||
|
getcmdtype={},
|
||||||
|
getcmdwintype={},
|
||||||
|
getcurpos={},
|
||||||
|
getcwd={},
|
||||||
|
getfontname={args={0, 1}},
|
||||||
|
getfperm={args=1},
|
||||||
|
getfsize={args=1},
|
||||||
|
getftime={args=1},
|
||||||
|
getftype={args=1},
|
||||||
|
getline={args={1, 2}},
|
||||||
|
getloclist={args=1, func='f_getqflist'},
|
||||||
|
getmatches={},
|
||||||
|
getpid={},
|
||||||
|
getpos={args=1},
|
||||||
|
getqflist={},
|
||||||
|
getreg={args={0, 3}},
|
||||||
|
getregtype={args={0, 1}},
|
||||||
|
gettabvar={args={2, 3}},
|
||||||
|
gettabwinvar={args={3, 4}},
|
||||||
|
getwinposx={},
|
||||||
|
getwinposy={},
|
||||||
|
getwinvar={args={2, 3}},
|
||||||
|
glob={args={1, 3}},
|
||||||
|
glob2regpat={args=1},
|
||||||
|
globpath={args={2, 4}},
|
||||||
|
has={args=1},
|
||||||
|
has_key={args=2},
|
||||||
|
haslocaldir={},
|
||||||
|
hasmapto={args={1, 3}},
|
||||||
|
highlightID={args=1, func='f_hlID'}, -- obsolete
|
||||||
|
highlight_exists={args=1, func='f_hlexists'}, -- obsolete
|
||||||
|
histadd={args=2},
|
||||||
|
histdel={args={1, 2}},
|
||||||
|
histget={args={1, 2}},
|
||||||
|
histnr={args=1},
|
||||||
|
hlID={args=1},
|
||||||
|
hlexists={args=1},
|
||||||
|
hostname={},
|
||||||
|
iconv={args=3},
|
||||||
|
indent={args=1},
|
||||||
|
index={args={2, 4}},
|
||||||
|
input={args={1, 3}},
|
||||||
|
inputdialog={args={1, 3}},
|
||||||
|
inputlist={args=1},
|
||||||
|
inputrestore={},
|
||||||
|
inputsave={},
|
||||||
|
inputsecret={args={1, 2}},
|
||||||
|
insert={args={2, 3}},
|
||||||
|
invert={args=1},
|
||||||
|
isdirectory={args=1},
|
||||||
|
islocked={args=1},
|
||||||
|
items={args=1},
|
||||||
|
jobclose={args={1, 2}},
|
||||||
|
jobresize={args=3},
|
||||||
|
jobsend={args=2},
|
||||||
|
jobstart={args={1, 2}},
|
||||||
|
jobstop={args=1},
|
||||||
|
jobwait={args={1, 2}},
|
||||||
|
join={args={1, 2}},
|
||||||
|
keys={args=1},
|
||||||
|
last_buffer_nr={}, -- obsolete
|
||||||
|
len={args=1},
|
||||||
|
libcall={args=3},
|
||||||
|
libcallnr={args=3},
|
||||||
|
line={args=1},
|
||||||
|
line2byte={args=1},
|
||||||
|
lispindent={args=1},
|
||||||
|
localtime={},
|
||||||
|
log={args=1},
|
||||||
|
log10={args=1},
|
||||||
|
map={args=2},
|
||||||
|
maparg={args={1, 4}},
|
||||||
|
mapcheck={args={1, 3}},
|
||||||
|
match={args={2, 4}},
|
||||||
|
matchadd={args={2, 4}},
|
||||||
|
matchaddpos={args={2, 4}},
|
||||||
|
matcharg={args=1},
|
||||||
|
matchdelete={args=1},
|
||||||
|
matchend={args={2, 4}},
|
||||||
|
matchlist={args={2, 4}},
|
||||||
|
matchstr={args={2, 4}},
|
||||||
|
max={args=1},
|
||||||
|
min={args=1},
|
||||||
|
mkdir={args={1, 3}},
|
||||||
|
mode={args={0, 1}},
|
||||||
|
msgpackdump={args=1},
|
||||||
|
msgpackparse={args=1},
|
||||||
|
nextnonblank={args=1},
|
||||||
|
nr2char={args={1, 2}},
|
||||||
|
['or']={args=2},
|
||||||
|
pathshorten={args=1},
|
||||||
|
pow={args=2},
|
||||||
|
prevnonblank={args=1},
|
||||||
|
printf={args=varargs(2)},
|
||||||
|
pumvisible={},
|
||||||
|
py3eval={args=1},
|
||||||
|
pyeval={args=1},
|
||||||
|
range={args={1, 3}},
|
||||||
|
readfile={args={1, 3}},
|
||||||
|
reltime={args={0, 2}},
|
||||||
|
reltimestr={args=1},
|
||||||
|
remove={args={2, 3}},
|
||||||
|
rename={args=2},
|
||||||
|
['repeat']={args=2},
|
||||||
|
resolve={args=1},
|
||||||
|
reverse={args=1},
|
||||||
|
round={args=1},
|
||||||
|
rpcnotify={args=varargs(2)},
|
||||||
|
rpcrequest={args=varargs(2)},
|
||||||
|
rpcstart={args={1, 2}},
|
||||||
|
rpcstop={args=1},
|
||||||
|
screenattr={args=2},
|
||||||
|
screenchar={args=2},
|
||||||
|
screencol={},
|
||||||
|
screenrow={},
|
||||||
|
search={args={1, 4}},
|
||||||
|
searchdecl={args={1, 3}},
|
||||||
|
searchpair={args={3, 7}},
|
||||||
|
searchpairpos={args={3, 7}},
|
||||||
|
searchpos={args={1, 4}},
|
||||||
|
serverlist={},
|
||||||
|
serverstart={args={0, 1}},
|
||||||
|
serverstop={args=1},
|
||||||
|
setbufvar={args=3},
|
||||||
|
setcharsearch={args=1},
|
||||||
|
setcmdpos={args=1},
|
||||||
|
setline={args=2},
|
||||||
|
setloclist={args={2, 3}},
|
||||||
|
setmatches={args=1},
|
||||||
|
setpos={args=2},
|
||||||
|
setqflist={args={1, 2}},
|
||||||
|
setreg={args={2, 3}},
|
||||||
|
settabvar={args=3},
|
||||||
|
settabwinvar={args=4},
|
||||||
|
setwinvar={args=3},
|
||||||
|
sha256={args=1},
|
||||||
|
shellescape={args={1, 2}},
|
||||||
|
shiftwidth={},
|
||||||
|
simplify={args=1},
|
||||||
|
sin={args=1},
|
||||||
|
sinh={args=1},
|
||||||
|
sort={args={1, 3}},
|
||||||
|
soundfold={args=1},
|
||||||
|
spellbadword={args={0, 1}},
|
||||||
|
spellsuggest={args={1, 3}},
|
||||||
|
split={args={1, 3}},
|
||||||
|
sqrt={args=1},
|
||||||
|
str2float={args=1},
|
||||||
|
str2nr={args={1, 2}},
|
||||||
|
strchars={args=1},
|
||||||
|
strdisplaywidth={args={1, 2}},
|
||||||
|
strftime={args={1, 2}},
|
||||||
|
stridx={args={2, 3}},
|
||||||
|
string={args=1},
|
||||||
|
strlen={args=1},
|
||||||
|
strpart={args={2, 3}},
|
||||||
|
strridx={args={2, 3}},
|
||||||
|
strtrans={args=1},
|
||||||
|
strwidth={args=1},
|
||||||
|
submatch={args={1, 2}},
|
||||||
|
substitute={args=4},
|
||||||
|
synID={args=3},
|
||||||
|
synIDattr={args={2, 3}},
|
||||||
|
synIDtrans={args=1},
|
||||||
|
synconcealed={args=2},
|
||||||
|
synstack={args=2},
|
||||||
|
system={args={1, 2}},
|
||||||
|
systemlist={args={1, 3}},
|
||||||
|
tabpagebuflist={args={0, 1}},
|
||||||
|
tabpagenr={args={0, 1}},
|
||||||
|
tabpagewinnr={args={1, 2}},
|
||||||
|
tagfiles={},
|
||||||
|
taglist={args=1},
|
||||||
|
tan={args=1},
|
||||||
|
tanh={args=1},
|
||||||
|
tempname={},
|
||||||
|
termopen={args={1, 2}},
|
||||||
|
test={args=1},
|
||||||
|
tolower={args=1},
|
||||||
|
toupper={args=1},
|
||||||
|
tr={args=3},
|
||||||
|
trunc={args=1},
|
||||||
|
type={args=1},
|
||||||
|
undofile={args=1},
|
||||||
|
undotree={},
|
||||||
|
uniq={args={1, 3}},
|
||||||
|
values={args=1},
|
||||||
|
virtcol={args=1},
|
||||||
|
visualmode={args={0, 1}},
|
||||||
|
wildmenumode={},
|
||||||
|
winbufnr={args=1},
|
||||||
|
wincol={},
|
||||||
|
winheight={args=1},
|
||||||
|
winline={},
|
||||||
|
winnr={args={0, 1}},
|
||||||
|
winrestcmd={},
|
||||||
|
winrestview={args=1},
|
||||||
|
winsaveview={},
|
||||||
|
winwidth={args=1},
|
||||||
|
writefile={args={2, 3}},
|
||||||
|
xor={args=2},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user