Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
eval.c File Reference
#include <assert.h>
#include <float.h>
#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
#include <msgpack.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/eval.h"
#include "nvim/buffer.h"
#include "nvim/channel.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/edit.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/os/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/hashtab.h"
#include "nvim/iconv.h"
#include "nvim/if_cscope.h"
#include "nvim/indent_c.h"
#include "nvim/indent.h"
#include "nvim/mark.h"
#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"
#include "nvim/map.h"
#include "nvim/file_search.h"
#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/popupmnu.h"
#include "nvim/profile.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/sha256.h"
#include "nvim/spell.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/main.h"
#include "nvim/mouse.h"
#include "nvim/terminal.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/decode.h"
#include "nvim/os/os.h"
#include "nvim/event/libuv_process.h"
#include "nvim/os/pty_process.h"
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
#include "nvim/event/time.h"
#include "nvim/os/time.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/os/dl.h"
#include "nvim/os/input.h"
#include "nvim/event/loop.h"
#include "nvim/lib/kvec.h"
#include "nvim/lib/khash.h"
#include "nvim/lib/queue.h"
#include "nvim/lua/executor.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/executor.h"
#include "nvim/eval/gc.h"
#include "nvim/macros.h"

Data Structures

struct  lval_S
struct  scriptvar_T
struct  funccall_S
 Structure used by trans_function_name() More...
struct  funcdict_T
struct  forinfo_T
struct  vimvar
struct  timer_T
struct  fst
 Structure holding VimL function definition. More...
struct  GetListLineCookie
struct  sortinfo_T
 struct storing information about current sort More...


#define DICT_MAXNEST   100 /* maximum nesting of lists and dicts */
#define AUTOLOAD_CHAR   '#'
#define globvarht   globvardict.dv_hashtab
 g: value More...
#define SCRIPT_SV(id)   (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])
#define SCRIPT_VARS(id)   (SCRIPT_SV(id)->sv_dict.dv_hashtab)
#define FC_ABORT   0x01
#define FC_RANGE   0x02
#define FC_DICT   0x04
#define FC_CLOSURE   0x08
#define FC_DELETED   0x10
#define FC_REMOVED   0x20
#define FUNCARG(fp, j)   ((char_u **)(fp->uf_args.ga_data))[j]
#define FUNCLINE(fp, j)   ((char_u **)(fp->uf_lines.ga_data))[j]
#define VAR_SHORT_LEN   20
 Short variable name length. More...
#define FIXVAR_CNT   12
 Number of fixed variables used for arguments. More...
#define VV_COMPAT   1 /* compatible, also used without "v:" */
#define VV_RO   2 /* read-only */
#define VV_RO_SBX   4 /* read-only in the sandbox */
#define VV(idx, name, type, flags)
#define vv_type   vv_di.di_tv.v_type
#define vv_nr   vv_di.di_tv.vval.v_number
#define vv_special   vv_di.di_tv.vval.v_special
#define vv_float   vv_di.di_tv.vval.v_float
#define vv_str   vv_di.di_tv.vval.v_string
#define vv_list   vv_di.di_tv.vval.v_list
#define vv_dict   vv_di.di_tv.vval.v_dict
#define vv_tv   vv_di.di_tv
#define vimvarht   vimvardict.dv_hashtab
 v: hashtab More...
#define FNE_INCL_BR   1 /* find_name_end(): include [] in name */
#define ABORTING(func)   abort = abort || func
#define FLEN_FIXED   40
#define SP_NOMOVE   0x01
 don't move cursor More...
#define SP_REPEAT   0x02
 repeat to find outer pair More...
#define SP_RETCOUNT   0x04
 return matchcount More...
#define SP_SETPCMARK   0x08
 set previous context mark More...
#define SP_START   0x10
 accept match at start position More...
#define SP_SUBPAT   0x20
 return nr of matching sub-pattern More...
#define SP_END   0x40
 leave cursor at end of match More...
#define SP_COLUMN   0x80
 start at cursor column More...
#define ITEM_COMPARE_FAIL   999
#define CHECK_PROVIDER(name)


typedef struct lval_S lval_T
typedef void(* FunPtr) (void)
typedef void(* VimLFunc) (typval_T *args, typval_T *rvar, FunPtr data)
 Prototype of C function that implements VimL function. More...
typedef struct fst VimLFuncDef
 Structure holding VimL function definition. More...


enum  SomeMatchType {
  kSomeMatch, kSomeMatchEnd, kSomeMatchList, kSomeMatchStr,
 Describe data to return from find_some_match() More...
enum  TransFunctionNameFlags {
 trans_function_name() flags More...
 get_lval() flags More...
enum  assert_type_T {
 Type of assert_* check being performed. More...
enum  DictListType { kDictListKeys, kDictListValues, kDictListItems }
 Type for dict_list function. More...
enum  exptype_T {
enum  FnameTransError {


void eval_init (void)
char_ufunc_name (void *cookie)
linenr_Tfunc_breakpoint (void *cookie)
int * func_dbg_tick (void *cookie)
int func_level (void *cookie)
int current_func_returned (void)
void set_internal_string_var (char_u *name, char_u *value)
int var_redir_start (char_u *name, int append)
void var_redir_str (char_u *value, int value_len)
void var_redir_stop (void)
int eval_charconvert (const char *const enc_from, const char *const enc_to, const char *const fname_from, const char *const fname_to)
int eval_printexpr (const char *const fname, const char *const args)
void eval_diff (const char *const origfile, const char *const newfile, const char *const outfile)
void eval_patch (const char *const origfile, const char *const difffile, const char *const outfile)
int eval_to_bool (char_u *arg, bool *error, char_u **nextcmd, int skip)
char * eval_to_string_skip (const char *arg, const char **nextcmd, const bool skip) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
int skip_expr (char_u **pp)
char_ueval_to_string (char_u *arg, char_u **nextcmd, int convert)
char_ueval_to_string_safe (char_u *arg, char_u **nextcmd, int use_sandbox)
varnumber_T eval_to_number (char_u *expr)
list_Teval_spell_expr (char_u *badword, char_u *expr)
int get_spellword (list_T *const list, const char **ret_word)
int call_vim_function (const char_u *func, int argc, const char_u *const *const argv, bool safe, int str_arg_only, typval_T *rettv)
varnumber_T call_func_retnr (char_u *func, int argc, const char_u *const *const argv, int safe)
char * call_func_retstr (const char *const func, int argc, const char_u *const *argv, bool safe) FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
void * call_func_retlist (char_u *func, int argc, const char_u *const *argv, bool safe)
void * save_funccal (void)
void restore_funccal (void *vfc)
void prof_child_enter (proftime_T *tm)
void prof_child_exit (proftime_T *tm)
int eval_foldexpr (char_u *arg, int *cp)
void ex_let (exarg_T *eap)
 if (len==0)
 memset (lp, 0, sizeof(lval_T))
 if (skip)
 if (expr_start!=NULL)
 if ((*p!= '['&&*p!= '.')||lp->ll_name==NULL)
 if (v==NULL &&!quiet)
whilep (*p== '.'&&lp->ll_tv->v_type==VAR_DICT)
void * eval_for_line (const char_u *arg, bool *errp, char_u **nextcmdp, int skip)
bool next_for_item (void *fi_void, char_u *arg)
void free_for_info (void *fi_void)
void set_context_for_expression (expand_T *xp, char_u *arg, cmdidx_T cmdidx)
void ex_call (exarg_T *eap)
void ex_unlet (exarg_T *eap)
void ex_lockvar (exarg_T *eap)
int do_unlet (const char *const name, const size_t name_len, const int forceit) FUNC_ATTR_NONNULL_ALL
void del_menutrans_vars (void)
char_uget_user_var_name (expand_T *xp, int idx)
int eval0 (char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate)
char_upartial_name (partial_T *pt)
void partial_unref (partial_T *pt)
bool func_equal (typval_T *tv1, typval_T *tv2, bool ic)
int get_copyID (void)
bool garbage_collect (bool testing)
bool set_ref_in_ht (hashtab_T *ht, int copyID, list_stack_T **list_stack) FUNC_ATTR_WARN_UNUSED_RESULT
bool set_ref_in_list (list_T *l, int copyID, ht_stack_T **ht_stack) FUNC_ATTR_WARN_UNUSED_RESULT
bool set_ref_in_item (typval_T *tv, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack) FUNC_ATTR_WARN_UNUSED_RESULT
bool set_ref_in_functions (int copyID)
 Set "copyID" in all functions available by name. More...
size_t string2float (const char *const text, float_T *const ret_value) FUNC_ATTR_NONNULL_ALL
char_uget_function_name (expand_T *xp, int idx)
char_uget_expr_name (expand_T *xp, int idx)
static char_u if (v!=NULL &&v->di_tv.v_type==VAR_FUNC)
 return (char_u *)
bool set_ref_in_func (char_u *name, ufunc_T *fp_in, int copyID)
int call_func (const char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, ArgvFunc argv_func, linenr_T firstline, linenr_T lastline, int *doesrange, bool evaluate, partial_T *partial, dict_T *selfdict_in)
void assert_inrange (typval_T *argvars)
int func_call (char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict, typval_T *rettv)
void get_user_input (const typval_T *const argvars, typval_T *const rettv, const bool inputdialog) FUNC_ATTR_NONNULL_ALL
void mapblock_fill_dict (dict_T *const dict, const mapblock_T *const mp, long buffer_value, bool compatible) FUNC_ATTR_NONNULL_ALL
long do_searchpair (char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit)
 if (list_arg->v_type!=VAR_LIST)
else if (recursive!=0)
 if (action_arg->v_type==VAR_UNKNOWN)
else if (action_arg->v_type!=VAR_STRING)
 if ((*act== 'a'||*act== 'r'||*act== ' '||*act== 'f')&&act[1]==NUL)
 if (title_arg->v_type==VAR_UNKNOWN)
 if (set_errorlist(wp, l, action,(char_u *) title, d)==OK)
bool callback_from_typval (Callback *const callback, typval_T *const arg) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
bool callback_call (Callback *const callback, const int argcount_in, typval_T *const argvars_in, typval_T *const rettv) FUNC_ATTR_NONNULL_ALL
void timer_teardown (void)
pos_Tvar2fpos (const typval_T *const tv, const int dollar_lnum, int *const ret_fnum) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
varnumber_T get_vim_var_nr (int idx) FUNC_ATTR_PURE
char_uget_vim_var_str (int idx) FUNC_ATTR_PURE FUNC_ATTR_NONNULL_RET
list_Tget_vim_var_list (int idx) FUNC_ATTR_PURE
dict_Tget_vim_var_dict (int idx) FUNC_ATTR_PURE
void set_vim_var_char (int c)
void set_vcount (long count, long count1, int set_prevcount)
void set_vim_var_nr (const VimVarIndex idx, const varnumber_T val)
void set_vim_var_special (const VimVarIndex idx, const SpecialVarValue val)
void set_vim_var_string (const VimVarIndex idx, const char *const val, const ptrdiff_t len)
void set_vim_var_list (const VimVarIndex idx, list_T *const val)
void set_vim_var_dict (const VimVarIndex idx, dict_T *const val)
void set_reg_var (int c)
char_uv_exception (char_u *oldval)
char_uv_throwpoint (char_u *oldval)
char_uset_cmdarg (exarg_T *eap, char_u *oldarg)
void set_selfdict (typval_T *rettv, dict_T *selfdict)
char_uget_var_value (const char *const name)
void new_script_vars (scid_T id)
void init_var_dict (dict_T *dict, ScopeDictDictItem *dict_var, int scope)
void unref_var_dict (dict_T *dict)
void vars_clear (hashtab_T *ht)
bool var_check_ro (const int flags, const char *name, size_t name_len) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
bool var_check_func_name (const char *const name, const bool new_var) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
bool valid_varname (const char *varname) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
int var_item_copy (const vimconv_T *const conv, typval_T *const from, typval_T *const to, const bool deep, const int copyID) FUNC_ATTR_NONNULL_ARG(2
 if (recurse >=DICT_MAXNEST)
 switch (from->v_type)
void ex_echo (exarg_T *eap)
void ex_echohl (exarg_T *eap)
void ex_execute (exarg_T *eap)
void ex_function (exarg_T *eap)
bool translated_function_exists (const char *name)
void func_dump_profile (FILE *fd)
char_uget_user_func_name (expand_T *xp, int idx)
void ex_delfunction (exarg_T *eap)
 ":delfunction {name}" More...
void func_unref (char_u *name)
void func_ptr_unref (ufunc_T *fp)
void func_ref (char_u *name)
 Count a reference to a Function. More...
void func_ptr_ref (ufunc_T *fp)
 Count a reference to a Function. More...
void call_user_func (ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, linenr_T firstline, linenr_T lastline, dict_T *selfdict) FUNC_ATTR_NONNULL_ARG(1
 if (depth >=p_mfd)
 save_search_patterns ()
 if (!ins_compl_active())
 line_breakcheck ()
ga_initfc (ufunc_T *), 1
 func_ptr_ref (fp)
 if (STRNCMP(fp->uf_name,"<lambda>", 8)==0)
 if (selfdict!=NULL)
 STRCPY (name,"000")
add_nr_var & fc (dictitem_T *)&fc->fixvar[fixvar_idx++],"firstline",(varnumber_T) firstline
 for (int i=0;i< argcount;i++)
 if (p_verbose >=12)
 if (func_not_yet_profiling_but_should)
 if (do_profiling_yes)
 do_cmdline (NULL, get_func_line,(void *) fc, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT)
 if ((did_emsg &&(fp->uf_flags &FC_ABORT))||rettv->v_type==VAR_UNKNOWN)
 if (func_or_func_caller_profiling)
 xfree (sourcing_name)
 if (p_verbose >=12 &&sourcing_name!=NULL)
 cleanup_function_call (fc)
 if (--fp->uf_calls<=0 &&fp->uf_refcount<=0)
 if (did_save_redo)
 restore_search_patterns ()
void ex_return (exarg_T *eap)
int do_return (exarg_T *eap, int reanimate, int is_cmd, void *rettv)
char_uget_return_cmd (void *rettv)
char_uget_func_line (int c, void *cookie, int indent)
void func_line_start (void *cookie)
void func_line_exec (void *cookie)
void func_line_end (void *cookie)
int func_has_ended (void *cookie)
int func_has_abort (void *cookie)
hashitem_Tfind_hi_in_scoped_ht (const char *name, hashtab_T **pht)
 Search hashitem in parent scope. More...
dictitem_Tfind_var_in_scoped_ht (const char *name, const size_t namelen, int no_autoload)
 Search variable in parent scope. More...
const void * var_shada_iter (const void *const iter, const char **const name, typval_T *rettv) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(2
 if (iter==NULL)
tv_copyTV_DICT_HI2DI (hi) ->di_tv, rettv
 while ((size_t)(++hi-hifirst)< hinum)
void var_set_global (const char *const name, typval_T vartv)
int store_session_globals (FILE *fd)
void last_set_msg (scid_T scriptID)
void option_last_set_msg (LastSet last_set)
void reset_v_option_vars (void)
int modify_fname (char_u *src, size_t *usedlen, char_u **fnamep, char_u **bufp, size_t *fnamelen)
char_udo_string_sub (char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags)
typval_T eval_call_provider (char *provider, char *method, list_T *arguments)
bool eval_has_provider (const char *name)
void eval_fmt_source_name_line (char *buf, size_t bufsize)
 Writes "<sourcing_name>:<sourcing_lnum>" to buf[bufsize]. More...
void ex_checkhealth (exarg_T *eap)
 ":checkhealth [plugins]" More...


hashtab_T func_hashtab
const list_Teval_msgpack_type_lists []
 Array mapping values from MessagePackType to corresponding list pointers. More...
funccall_Tcurrent_funccal = NULL
funccall_Tprevious_funccal = NULL
int len = get_env_len((const char_u **)&arg)
int opt_flags
char_utofree = NULL
if arg
char * name = (char *)arg
return arg_end
static char_u typval_T var1
typval_T var2
int empty1 = FALSE
int quiet = flags & GLV_QUIET
lp ll_name_len = (size_t)((const char *)p - lp->ll_name)
lp ll_tv = &v->di_tv
var1 v_type = VAR_UNKNOWN
static void const char * title = NULL
int action = ' '
rettv vval v_number = -1
dict_Td = NULL
typval_Tlist_arg = &args[0]
typval_Taction_arg = &args[1]
const char *const act = tv_get_string_chk(action_arg)
typval_Ttitle_arg = &args[2]
skip_args __pad0__
list_T *const l = list_arg->vval.v_list
int int ret = OK
void linenr_T save_sourcing_lnum
scid_T save_current_SID = current_SID
funccall_Tfc = xmalloc(sizeof(funccall_T))
int save_did_emsg = did_emsg
int fixvar_idx = 0
int ai
bool islambda = false
char_u numbuf [NUMBUFLEN]
proftime_T wait_start
proftime_T call_start
bool did_save_redo = false
save_redo_T save_redo
fp uf_calls
fc caller = current_funccal
fc func = fp
fc rettv = rettv
fc linenr = 0
fc returned = FALSE
fc level = ex_nesting_level
fc breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0)
fc dbg_tick = debug_tick
fc fc_refcount = 0
fc fc_copyID = 0
v di_flags = DI_FLAGS_RO | DI_FLAGS_FIX
v di_tv v_lock = VAR_FIXED
v di_tv vval v_list = &fc->l_varlist
 save_sourcing_name = sourcing_name
 sourcing_lnum = 1
 sourcing_name = xmalloc(len)
const bool do_profiling_yes = do_profiling == PROF_YES
bool func_not_yet_profiling_but_should
 current_SID = fp->uf_script_ID
 did_emsg = FALSE
const void const hashitem_Thifirst = globvarht.ht_array
const size_t hinum = (size_t) globvarht.ht_mask + 1
return NULL

Macro Definition Documentation

#define ABORTING (   func)    abort = abort || func
#define AUTOLOAD_CHAR   '#'
#define CHECK_PROVIDER (   name)
if (has_##name == -1) { \
has_##name = !!find_func((char_u *)"provider#" #name "#Call"); \
if (!has_##name) { \
script_autoload("provider#" #name "#Call", \
sizeof("provider#" #name "#Call") - 1, \
false); \
has_##name = !!find_func((char_u *)"provider#" #name "#Call"); \
} \
char * name
Definition: eval.c:1850
unsigned char char_u
Definition: types.h:11
Definition: eval.c:1852
#define DICT_MAXNEST   100 /* maximum nesting of lists and dicts */
#define FC_ABORT   0x01
#define FC_CLOSURE   0x08
#define FC_DELETED   0x10
#define FC_DICT   0x04
#define FC_RANGE   0x02
#define FC_REMOVED   0x20
#define FIXVAR_CNT   12

Number of fixed variables used for arguments.

#define FLEN_FIXED   40
2 /* find_name_end(): check name starts with
valid character */
#define FNE_INCL_BR   1 /* find_name_end(): include [] in name */
#define FUNCARG (   fp,
)    ((char_u **)(fp->uf_args.ga_data))[j]
#define FUNCLINE (   fp,
)    ((char_u **)(fp->uf_lines.ga_data))[j]
#define globvarht   globvardict.dv_hashtab

g: value

#define ITEM_COMPARE_FAIL   999
#define SCRIPT_SV (   id)    (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])
#define SCRIPT_VARS (   id)    (SCRIPT_SV(id)->sv_dict.dv_hashtab)
#define SP_COLUMN   0x80

start at cursor column

#define SP_END   0x40

leave cursor at end of match

#define SP_NOMOVE   0x01

don't move cursor

#define SP_REPEAT   0x02

repeat to find outer pair

#define SP_RETCOUNT   0x04

return matchcount

#define SP_SETPCMARK   0x08

set previous context mark

#define SP_START   0x10

accept match at start position

#define SP_SUBPAT   0x20

return nr of matching sub-pattern

#define VAR_SHORT_LEN   20

Short variable name length.

#define vimvarht   vimvardict.dv_hashtab

v: hashtab

#define VV (   idx,
[idx] = { \
.vv_name = name, \
.vv_di = { \
.di_tv = { .v_type = type }, \
.di_flags = 0, \
.di_key = { 0 }, \
}, \
.vv_flags = flags, \
char * name
Definition: eval.c:1850
err type
Definition: helpers.c:1169
#define VV_COMPAT   1 /* compatible, also used without "v:" */
#define vv_dict   vv_di.di_tv.vval.v_dict
#define vv_float   vv_di.di_tv.vval.v_float
#define vv_list   vv_di.di_tv.vval.v_list
#define vv_nr   vv_di.di_tv.vval.v_number
#define VV_RO   2 /* read-only */
#define VV_RO_SBX   4 /* read-only in the sandbox */
#define vv_special   vv_di.di_tv.vval.v_special
#define vv_str   vv_di.di_tv.vval.v_string
#define vv_tv   vv_di.di_tv
#define vv_type   vv_di.di_tv.v_type

Typedef Documentation

typedef void(* FunPtr) (void)
typedef struct lval_S lval_T
typedef void(* VimLFunc) (typval_T *args, typval_T *rvar, FunPtr data)

Prototype of C function that implements VimL function.

typedef struct fst VimLFuncDef

Structure holding VimL function definition.

Enumeration Type Documentation

Type of assert_* check being performed.


Type for dict_list function.


List dictionary keys.


List dictionary values.


List dictionary contents: [keys, values].

enum exptype_T

get_lval() flags


Do not emit error messages.


Do not use script autoloading.


Indicates that caller will not change the value (prevents error message).

Describe data to return from find_some_match()


Data for match().


Data for matchend().


Data for matchlist().


Data for matchstr().


Data for matchstrpos().

trans_function_name() flags


May use internal function name.


Do not emit error messages.


Do not use script autoloading.


Do not dereference a Funcref.


Will not change the variable.


Function Documentation

void assert_inrange ( typval_T argvars)
int call_func ( const char_u funcname,
int  len,
typval_T rettv,
int  argcount_in,
typval_T argvars_in,
ArgvFunc  argv_func,
linenr_T  firstline,
linenr_T  lastline,
int *  doesrange,
bool  evaluate,
partial_T partial,
dict_T selfdict_in 

Call a function with its resolved parameters

"argv_func", when not NULL, can be used to fill in arguments only when the invoked function uses them. It is called like this: new_argcount = argv_func(current_argcount, argv, called_func_argcount)

FAIL if function cannot be called, else OK (even if an error occurred while executing the function! Set msg_list to capture the error, see do_cmdline()).
void* call_func_retlist ( char_u func,
int  argc,
const char_u *const *  argv,
bool  safe 

Call Vim script function and return the result as a List

[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with string arguments.
[in]safeUse the sandbox.
[allocated] NULL when calling function fails or return tv is not a List, allocated List otherwise.
varnumber_T call_func_retnr ( char_u func,
int  argc,
const char_u *const *const  argv,
int  safe 

Call Vim script function and return the result as a number

[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with string arguments.
[in]safeUse with sandbox.
-1 when calling function fails, result of function otherwise.
char* call_func_retstr ( const char *const  func,
int  argc,
const char_u *const *  argv,
bool  safe 

Call Vim script function and return the result as a string

[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with string arguments.
[in]safeUse the sandbox.
[allocated] NULL when calling function fails, allocated string otherwise.
void call_user_func ( ufunc_T fp,
int  argcount,
typval_T argvars,
typval_T rettv,
linenr_T  firstline,
linenr_T  lastline,
dict_T selfdict 

Call a user function

fpFunction to call.
[in]argcountNumber of arguments.
[out]rettvReturn value.
[in]firstlineFirst line of range.
[in]lastlineLast line of range.
selfdictDictionary for "self" for dictionary functions.
int call_vim_function ( const char_u func,
int  argc,
const char_u *const *const  argv,
bool  safe,
int  str_arg_only,
typval_T rettv 
bool callback_call ( Callback *const  callback,
const int  argcount_in,
typval_T *const  argvars_in,
typval_T *const  rettv 
bool callback_from_typval ( Callback *const  callback,
typval_T *const  arg 
cleanup_function_call ( fc  )
int current_func_returned ( void  )
void del_menutrans_vars ( void  )
do_cmdline ( NULL  ,
get_func_line  ,
(void *)  fc,
int do_return ( exarg_T eap,
int  reanimate,
int  is_cmd,
void *  rettv 
long do_searchpair ( char_u spat,
char_u mpat,
char_u epat,
int  dir,
char_u skip,
int  flags,
pos_T match_pos,
linenr_T  lnum_stop,
long  time_limit 
char_u* do_string_sub ( char_u str,
char_u pat,
char_u sub,
typval_T expr,
char_u flags 

Perform a substitution on "str" with pattern "pat" and substitute "sub". When "sub" is NULL "expr" is used, must be a VAR_FUNC or VAR_PARTIAL. "flags" can be "g" to do a global substitute. Returns an allocated string, NULL for error.

int do_unlet ( const char *const  name,
const size_t  name_len,
const int  forceit 

unlet a variable

[in]nameVariable name to unlet.
[in]name_lenVariable name length.
[in]fonceitIf true, do not complain if variable doesn’t exist.
OK if it existed, FAIL otherwise.
int eval0 ( char_u arg,
typval_T rettv,
char_u **  nextcmd,
int  evaluate 
typval_T eval_call_provider ( char *  provider,
char *  method,
list_T arguments 
int eval_charconvert ( const char *const  enc_from,
const char *const  enc_to,
const char *const  fname_from,
const char *const  fname_to 
void eval_diff ( const char *const  origfile,
const char *const  newfile,
const char *const  outfile 
void eval_fmt_source_name_line ( char *  buf,
size_t  bufsize 

Writes "<sourcing_name>:<sourcing_lnum>" to buf[bufsize].

int eval_foldexpr ( char_u arg,
int *  cp 
void* eval_for_line ( const char_u arg,
bool *  errp,
char_u **  nextcmdp,
int  skip 
bool eval_has_provider ( const char *  name)
void eval_init ( void  )
void eval_patch ( const char *const  origfile,
const char *const  difffile,
const char *const  outfile 
int eval_printexpr ( const char *const  fname,
const char *const  args 
list_T* eval_spell_expr ( char_u badword,
char_u expr 
int eval_to_bool ( char_u arg,
bool *  error,
char_u **  nextcmd,
int  skip 
varnumber_T eval_to_number ( char_u expr)
char_u* eval_to_string ( char_u arg,
char_u **  nextcmd,
int  convert 
char_u* eval_to_string_safe ( char_u arg,
char_u **  nextcmd,
int  use_sandbox 
char* eval_to_string_skip ( const char *  arg,
const char **  nextcmd,
const bool  skip 

Top level evaluation function, returning a string

[in]argString to evaluate.
nextcmdPointer to the start of the next Ex command.
[in]skipIf true, only do parsing to nextcmd without reporting errors or actually evaluating anything.
[allocated] string result of evaluation or NULL in case of error or when skipping.
void ex_call ( exarg_T eap)
void ex_checkhealth ( exarg_T eap)

":checkhealth [plugins]"

void ex_delfunction ( exarg_T eap)

":delfunction {name}"

void ex_echo ( exarg_T eap)
void ex_echohl ( exarg_T eap)
void ex_execute ( exarg_T eap)
void ex_function ( exarg_T eap)
void ex_let ( exarg_T eap)
void ex_lockvar ( exarg_T eap)
void ex_return ( exarg_T eap)
void ex_unlet ( exarg_T eap)
ga_init& fc ( ufunc_T )
add_nr_var& fc ( dictitem_T ) -> fixvar[fixvar_idx++],"firstline",(varnumber_T) firstline
hashitem_T* find_hi_in_scoped_ht ( const char *  name,
hashtab_T **  pht 

Search hashitem in parent scope.

dictitem_T* find_var_in_scoped_ht ( const char *  name,
const size_t  namelen,
int  no_autoload 

Search variable in parent scope.

for ( )
void free_for_info ( void *  fi_void)
linenr_T* func_breakpoint ( void *  cookie)
int func_call ( char_u name,
typval_T args,
partial_T partial,
dict_T selfdict,
typval_T rettv 
int* func_dbg_tick ( void *  cookie)
void func_dump_profile ( FILE *  fd)
bool func_equal ( typval_T tv1,
typval_T tv2,
bool  ic 
int func_has_abort ( void *  cookie)
int func_has_ended ( void *  cookie)
int func_level ( void *  cookie)
void func_line_end ( void *  cookie)
void func_line_exec ( void *  cookie)
void func_line_start ( void *  cookie)
char_u* func_name ( void *  cookie)
void func_ptr_ref ( ufunc_T fp)

Count a reference to a Function.

func_ptr_ref ( fp  )
void func_ptr_unref ( ufunc_T fp)

Unreference a Function: decrement the reference count and free it when it becomes zero. Unreference user function, freeing it if needed

Decrements the reference count and frees when it becomes zero.

fpFunction to unreference.
void func_ref ( char_u name)

Count a reference to a Function.

void func_unref ( char_u name)
bool garbage_collect ( bool  testing)

Do garbage collection for lists and dicts.

testingtrue if called from test_garbagecollect_now().
true if some memory was freed.
int get_copyID ( void  )

Get next (unique) copy ID

Used for traversing nested structures e.g. when serializing them or garbage collecting.

char_u* get_expr_name ( expand_T xp,
int  idx 
char_u* get_func_line ( int  c,
void *  cookie,
int  indent 
char_u* get_function_name ( expand_T xp,
int  idx 
char_u* get_return_cmd ( void *  rettv)
int get_spellword ( list_T *const  list,
const char **  ret_word 

Get spell word from an entry from spellsuggest=expr:

Entry in question is supposed to be a list (to be checked by the caller) with two items: a word and a score represented as an unsigned number (whether it actually is unsigned is not checked).

Used to get the good word and score from the eval_spell_expr() result.

[in]listList to get values from.
[out]ret_wordSuggested word. Not initialized if return value is -1.
-1 in case of error, score otherwise.
char_u* get_user_func_name ( expand_T xp,
int  idx 
void get_user_input ( const typval_T *const  argvars,
typval_T *const  rettv,
const bool  inputdialog 
char_u* get_user_var_name ( expand_T xp,
int  idx 
char_u* get_var_value ( const char *const  name)
dict_T* get_vim_var_dict ( int  idx)

Get Dictionary v: variable value. Caller must take care of reference count when needed.

list_T* get_vim_var_list ( int  idx)
varnumber_T get_vim_var_nr ( int  idx)
char_u* get_vim_var_str ( int  idx)
if ( len  = = 0)
if ( skip  )
if ( expr_start!  = NULL)
if ( *!= '['&&*!= '.'p||lp->  ll_name = NULL)
if ( v  = NULL && !quiet)
if ( v!  = NULL && v->di_tv.v_type == VAR_FUNC)
if ( list_arg->v_type!  = VAR_LIST)
else if ( recursive!  = 0)
if ( action_arg->  v_type = VAR_UNKNOWN)
else if ( action_arg->v_type!  = VAR_STRING)
if ( *== ''||*== ''||*== ' '||*== ''f &&  act[1] = NUL)
else if ( title_arg->  v_type = VAR_UNKNOWN)
if ( set_errorlist(wp, l, action,(char_u *) title, d = OK)
if ( recurse >=  DICT_MAXNEST)
if ( depth >=  p_mfd)
if ( ins_compl_active())
if ( STRNCMP(fp->uf_name,"<lambda>", 8)  = = 0)
if ( selfdict!  = NULL)
if ( p_verbose >=  12)
if ( do_profiling_yes  )
if ( (did_emsg &&(fp->uf_flags &FC_ABORT))||rettv->  v_type = VAR_UNKNOWN)
if ( func_or_func_caller_profiling  )
if ( p_verbose >=12 &&sourcing_name!  = NULL)
if ( --fp->uf_calls<=0 &&fp->uf_refcount<=  0)
if ( did_save_redo  )
if ( iter  = NULL)
void init_var_dict ( dict_T dict,
ScopeDictDictItem *  dict_var,
int  scope 
void last_set_msg ( scid_T  scriptID)
line_breakcheck ( )
void mapblock_fill_dict ( dict_T *const  dict,
const mapblock_T *const  mp,
long  buffer_value,
bool  compatible 

Fill a dictionary with all applicable maparg() like dictionaries

dictThe dictionary to be filled
mpThe maphash that contains the mapping information
buffer_valueThe "buffer" value
compatibleTrue for compatible with old maparg() dict
memset ( lp  ,
int modify_fname ( char_u src,
size_t *  usedlen,
char_u **  fnamep,
char_u **  bufp,
size_t *  fnamelen 
void new_script_vars ( scid_T  id)
bool next_for_item ( void *  fi_void,
char_u arg 
void option_last_set_msg ( LastSet  last_set)

Displays where an option was last set.

Should only be invoked when 'verbose' is non-zero.

while* p ( p = = '.' && lp->ll_tv->v_type == VAR_DICT)
char_u* partial_name ( partial_T pt)
the function name of the partial.
void partial_unref ( partial_T pt)

Unreference a closure: decrement the reference count and free it when it becomes zero.

void prof_child_enter ( proftime_T tm)
void prof_child_exit ( proftime_T tm)
void reset_v_option_vars ( void  )
void restore_funccal ( void *  vfc)
restore_search_patterns ( )
return ( char_u )
void* save_funccal ( void  )
save_search_patterns ( )
char_u* set_cmdarg ( exarg_T eap,
char_u oldarg 
void set_context_for_expression ( expand_T xp,
char_u arg,
cmdidx_T  cmdidx 
void set_internal_string_var ( char_u name,
char_u value 
bool set_ref_in_func ( char_u name,
ufunc_T fp_in,
int  copyID 

Mark all lists and dicts referenced through function "name" with "copyID". "list_stack" is used to add lists to be marked. Can be NULL. "ht_stack" is used to add hashtabs to be marked. Can be NULL.

true if setting references failed somehow.
bool set_ref_in_functions ( int  copyID)

Set "copyID" in all functions available by name.

bool set_ref_in_ht ( hashtab_T ht,
int  copyID,
list_stack_T **  list_stack 

Mark all lists and dicts referenced through hashtab "ht" with "copyID".

htHashtab content will be marked.
copyIDNew mark for lists and dicts.
list_stackUsed to add lists to be marked. Can be NULL.
true if setting references failed somehow.
bool set_ref_in_item ( typval_T tv,
int  copyID,
ht_stack_T **  ht_stack,
list_stack_T **  list_stack 

Mark all lists and dicts referenced through typval "tv" with "copyID".

tvTypval content will be marked.
copyIDNew mark for lists and dicts.
ht_stackUsed to add hashtabs to be marked. Can be NULL.
list_stackUsed to add lists to be marked. Can be NULL.
true if setting references failed somehow.
bool set_ref_in_list ( list_T l,
int  copyID,
ht_stack_T **  ht_stack 

Mark all lists and dicts referenced through list "l" with "copyID".

lList content will be marked.
copyIDNew mark for lists and dicts.
ht_stackUsed to add hashtabs to be marked. Can be NULL.
true if setting references failed somehow.
void set_reg_var ( int  c)
void set_selfdict ( typval_T rettv,
dict_T selfdict 
void set_vcount ( long  count,
long  count1,
int  set_prevcount 
void set_vim_var_char ( int  c)
void set_vim_var_dict ( const VimVarIndex  idx,
dict_T *const  val 

Set Dictionary v: variable to the given dictionary

[in]idxIndex of variable to set.
[in,out]valValue to set to. Reference count will be incremented. Also keys of the dictionary will be made read-only.
void set_vim_var_list ( const VimVarIndex  idx,
list_T *const  val 

Set list v: variable to the given list

[in]idxIndex of variable to set.
[in,out]valValue to set to. Reference count will be incremented.
void set_vim_var_nr ( const VimVarIndex  idx,
const varnumber_T  val 

Set number v: variable to the given value

[in]idxIndex of variable to set.
[in]valValue to set to.
void set_vim_var_special ( const VimVarIndex  idx,
const SpecialVarValue  val 

Set special v: variable to the given value

[in]idxIndex of variable to set.
[in]valValue to set to.
void set_vim_var_string ( const VimVarIndex  idx,
const char *const  val,
const ptrdiff_t  len 

Set string v: variable to the given string

[in]idxIndex of variable to set.
[in]valValue to set to. Will be copied.
[in]lenLegth of that value or -1 in which case strlen() will be used.
int skip_expr ( char_u **  pp)
int store_session_globals ( FILE *  fd)
STRCPY ( name  ,
size_t string2float ( const char *const  text,
float_T *const  ret_value 

Convert the string to a floating point number

This uses strtod(). setlocale(LC_NUMERIC, "C") has been used earlier to make sure this always uses a decimal point.

[in]textString to convert.
[out]ret_valueLocation where conversion result is saved.
Length of the text that was consumed.
switch ( from->  v_type)
void timer_teardown ( void  )
bool translated_function_exists ( const char *  name)
tv_copy& TV_DICT_HI2DI ( hi  ) -> di_tv, rettv
void unref_var_dict ( dict_T dict)
char_u* v_exception ( char_u oldval)
char_u* v_throwpoint ( char_u oldval)
bool valid_varname ( const char *  varname)

Check if a variable name is valid

[in]varnameVariable name to check.
false when variable name is not valid, true when it is. Also gives an error message if appropriate.
pos_T* var2fpos ( const typval_T *const  tv,
const int  dollar_lnum,
int *const  ret_fnum 

Translate a VimL object into a position

Accepts VAR_LIST and VAR_STRING objects. Does not give an error for invalid type.

[in]tvObject to translate.
[in]dollar_lnumTrue when "$" is last line.
[out]ret_fnumSet to fnum for marks.
Pointer to position or NULL in case of error (e.g. invalid type).
bool var_check_func_name ( const char *const  name,
const bool  new_var 

Check if name is a valid name to assign funcref to

[in]namePossible function/funcref name.
[in]new_varTrue if it is a name for a variable.
false in case of error, true in case of success. Also gives an error message if appropriate.
bool var_check_ro ( const int  flags,
const char *  name,
size_t  name_len 

Check whether variable is read-only (DI_FLAGS_RO, DI_FLAGS_RO_SBX)

Also gives an error message.

[in]flagsdi_flags attribute value.
[in]nameVariable name, for use in error message.
[in]name_lenVariable name length. Use TV_TRANSLATE to translate variable name and compute the length. Use TV_CSTRING to compute the length with strlen() without translating.

Both #TV_… values are used for optimization purposes: variable name with its length is needed only in case of error, when no error occurs computing them is a waste of CPU resources. This especially applies to gettext.

True if variable is read-only: either always or in sandbox when sandbox is enabled, false otherwise.
int var_item_copy ( const vimconv_T *const  conv,
typval_T *const  from,
typval_T *const  to,
const bool  deep,
const int  copyID 

Make a copy of an item

Lists and Dictionaries are also copied.

[in]convIf not NULL, convert all copied strings.
[in]fromValue to copy.
[out]toLocation where to copy to.
[in]deepIf true, use copy the container and all of the contained containers (nested).
[in]copyIDIf non-zero then when container is referenced more then once then copy of it that was already done is used. E.g. when copying list list = [list2, list2] (list[0] is list[1]) var_item_copy with zero copyID will emit a copy with (copy[0] isnot copy[1]), with non-zero it will emit a copy with (copy[0] is copy[1]) like in the original list. Not used when deep is false.
int var_redir_start ( char_u name,
int  append 
void var_redir_stop ( void  )
void var_redir_str ( char_u value,
int  value_len 
void var_set_global ( const char *const  name,
typval_T  vartv 
const void* var_shada_iter ( const void *const  iter,
const char **const  name,
typval_T rettv 

Iterate over global variables

No modifications to global variable dictionary must be performed while iteration is in progress.
[in]iterIterator. Pass NULL to start iteration.
[out]nameVariable name.
[out]rettvVariable value.
Pointer that needs to be passed to next var_shada_iter invocation or NULL to indicate that iteration is over.
void vars_clear ( hashtab_T ht)
while ( )
xfree ( sourcing_name  )

Variable Documentation

skip_args __pad0__
const char* const act = tv_get_string_chk(action_arg)
int action = ' '
typval_T* action_arg = &args[1]
int ai
if arg
Initial value:
if arg
Definition: eval.c:1847
return arg_end
fc breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0)
proftime_T call_start
fc caller = current_funccal
current_funccal = NULL
current_SID = fp->uf_script_ID
dict_T* d = NULL
fc dbg_tick = debug_tick
v di_flags = DI_FLAGS_RO | DI_FLAGS_FIX
did_emsg = FALSE
bool did_save_redo = false
const bool do_profiling_yes = do_profiling == PROF_YES
int empty1 = FALSE
const list_T* eval_msgpack_type_lists[]
Initial value:
= {
[kMPNil] = NULL,
[kMPMap] = NULL,
[kMPExt] = NULL,
Definition: eval.h:119
Definition: eval.h:120
Definition: eval.h:124
return NULL
Definition: eval.c:22198
Definition: eval.h:118
Definition: eval.h:121
Definition: eval.h:117
Definition: eval.h:116
Definition: eval.h:123
Definition: eval.h:122

Array mapping values from MessagePackType to corresponding list pointers.

char_u* expr_end
char_u* expr_start
add_nr_var & fc = xmalloc(sizeof(funccall_T))
fc fc_copyID = 0
fc fc_refcount = 0
int fixvar_idx = 0
fc func = fp
Initial value:
return NULL
Definition: eval.c:22198
return arg_end
Definition: eval.c:1988
unsigned char char_u
Definition: types.h:11
hashtab_T func_hashtab
bool func_not_yet_profiling_but_should
Initial value:
&& !fp->uf_profiling && has_profiling(false, fp->uf_name, NULL)
return NULL
Definition: eval.c:22198
bool has_profiling(bool file, char_u *fname, bool *fp)
Definition: ex_cmds2.c:773
const bool do_profiling_yes
Definition: eval.c:21549
FILE * fp
Definition: undo.c:1063
const void const hashitem_T* hifirst = globvarht.ht_array
const size_t hinum = (size_t) globvarht.ht_mask + 1
hashtab_T* ht
bool islambda = false
size_t len = get_env_len((const char_u **)&arg)
fc level = ex_nesting_level
fc linenr = 0
typval_T* list_arg = &args[0]
lp ll_name_len = (size_t)((const char *)p - lp->ll_name)
lp ll_tv = &v->di_tv
* name = (char *)arg
return NULL
char_u numbuf[NUMBUFLEN]
int opt_flags
while p
Initial value:
= (char_u *)find_name_end(name,
(const char_u **)&expr_start,
(const char_u **)&expr_end,
char_u * expr_end
Definition: eval.c:2041
char * name
Definition: eval.c:1850
unsigned char char_u
Definition: types.h:11
char_u * expr_start
Definition: eval.c:2040
funccall_T* previous_funccal = NULL
int quiet = flags & GLV_QUIET
return ret = OK
fc rettv = rettv
fc returned = FALSE
save_current_SID = current_SID
save_did_emsg = did_emsg
save_redo_T save_redo
Initial value:
unsigned char char_u
Definition: types.h:11
Definition: eval.c:21485
save_sourcing_name = sourcing_name
sourcing_lnum = 1
sourcing_name = xmalloc(len)
void const char* title = NULL
typval_T* title_arg = &args[2]
char_u* tofree = NULL
fp uf_calls
Initial value:
= find_var(lp->ll_name, lp->ll_name_len,
(flags & GLV_READ_ONLY) ? NULL : &ht,
return NULL
Definition: eval.c:22198
Do not use script autoloading.
Definition: eval.c:239
hashtab_T * ht
Definition: eval.c:2026
Definition: eval.c:240
v di_tv vval v_list = &fc->l_varlist
v di_tv v_lock = VAR_FIXED
rettv vval v_number = -1
v di_tv v_type = VAR_UNKNOWN
tv_clear & var1
Initial value:
Definition: coverity-model.c:65
Definition: eval.c:2082
typval_T var2
proftime_T wait_start