Data Structures | Macros | Functions | Variables
eval.c File Reference
#include <math.h>
#include <stdlib.h>
#include "auto/config.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/executor.h"
#include "nvim/eval/gc.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_getln.h"
#include "nvim/ex_session.h"
#include "nvim/fileio.h"
#include "nvim/getchar.h"
#include "nvim/highlight_group.h"
#include "nvim/lua/executor.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/move.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/shell.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/sign.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"

Data Structures

struct  scriptvar_T
 
struct  forinfo_T
 
struct  vimvar
 

Macros

#define DICT_MAXNEST   100
 
#define SCRIPT_SV(id)   (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])
 
#define SCRIPT_VARS(id)   (SCRIPT_SV(id)->sv_dict.dv_hashtab)
 
#define VV_COMPAT   1
 
#define VV_RO   2
 
#define VV_RO_SBX   4
 
#define VV(idx, name, type, flags)
 
#define VIMVAR_KEY_LEN   16
 
#define vv_type   vv_di.di_tv.v_type
 
#define vv_nr   vv_di.di_tv.vval.v_number
 
#define vv_bool   vv_di.di_tv.vval.v_bool
 
#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_blob   vv_di.di_tv.vval.v_blob
 
#define vv_partial   vv_di.di_tv.vval.v_partial
 
#define vv_tv   vv_di.di_tv
 
#define vimvarht   vimvardict.dv_hashtab
 v: hashtab More...
 
#define ABORTING(func)   abort = abort || func
 

Functions

dict_Tget_v_event (save_v_event_T *sve)
 
void restore_v_event (dict_T *v_event, save_v_event_T *sve)
 
varnumber_T num_divide (varnumber_T n1, varnumber_T n2) FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT
 
varnumber_T num_modulus (varnumber_T n1, varnumber_T n2) FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT
 
void eval_init (void)
 Initialize the global and v: variables. More...
 
void set_internal_string_var (const char *name, char *value) FUNC_ATTR_NONNULL_ARG(1)
 
int var_redir_start (char *name, int append)
 
void var_redir_str (char *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 *arg, bool *error, char **nextcmd, int skip)
 
 if (ret==FAIL)
 
bool eval_expr_valid_arg (const typval_T *const tv) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_CONST
 
int eval_expr_typval (const typval_T *expr, typval_T *argv, int argc, typval_T *rettv) FUNC_ATTR_NONNULL_ARG(1
 
int if (expr->v_type==VAR_FUNC)
 
 if (s==NULL)
 
 if (eval1_emsg(&s, rettv, true)==FAIL)
 
ifskipwhite (s) !=NUL
 
bool eval_expr_to_bool (const typval_T *expr, bool *error) FUNC_ATTR_NONNULL_ARG(1
 
bool if (eval_expr_typval(expr, &argv, 0, &rettv)==FAIL)
 
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 **pp)
 
char * eval_to_string (char *arg, char **nextcmd, bool convert)
 
char * eval_to_string_safe (char *arg, char **nextcmd, int use_sandbox)
 
varnumber_T eval_to_number (char *expr)
 
typval_Teval_expr (char *arg)
 
void prepare_vimvar (int idx, typval_T *save_tv)
 
void restore_vimvar (int idx, typval_T *save_tv)
 
void find_win_for_curbuf (void)
 If there is a window for "curbuf", make it the current window. More...
 
list_Teval_spell_expr (char *badword, char *expr)
 
int get_spellword (list_T *const list, const char **ret_word)
 
int call_vim_function (const char *func, int argc, typval_T *argv, typval_T *rettv) FUNC_ATTR_NONNULL_ALL
 
varnumber_T call_func_retnr (const char *func, int argc, typval_T *argv) FUNC_ATTR_NONNULL_ALL
 
char * call_func_retstr (const char *const func, int argc, typval_T *argv) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
 
voidcall_func_retlist (const char *func, int argc, typval_T *argv) FUNC_ATTR_NONNULL_ALL
 
void prof_child_enter (proftime_T *tm)
 
void prof_child_exit (proftime_T *tm)
 
int eval_foldexpr (char *arg, int *cp)
 
void ex_const (exarg_T *eap)
 
void ex_let (exarg_T *eap)
 
void list_hashtable_vars (hashtab_T *ht, const char *prefix, int empty, int *first)
 
 if (len==0)
 
char * get_lval (char *const name, typval_T *const rettv, lval_T *const lp, const bool unlet, const bool skip, const int flags, const int fne_flags) FUNC_ATTR_NONNULL_ARG(1
 
 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 clear_lval (lval_T *lp)
 Clear lval "lp" that was filled by get_lval(). More...
 
voideval_for_line (const char *arg, bool *errp, char **nextcmdp, int skip)
 
bool next_for_item (void *fi_void, char *arg)
 
void free_for_info (void *fi_void)
 Free the structure used to store info used by ":for". More...
 
void set_context_for_expression (expand_T *xp, char *arg, cmdidx_T cmdidx) FUNC_ATTR_NONNULL_ALL
 
void ex_unlet (exarg_T *eap)
 ":unlet[!] var1 ... " command. More...
 
void ex_lockvar (exarg_T *eap)
 ":lockvar" and ":unlockvar" commands More...
 
int do_unlet (const char *const name, const size_t name_len, const bool forceit) FUNC_ATTR_NONNULL_ALL
 
 if (deep==0)
 
 if (lp->ll_tv==NULL)
 
else if (lp->ll_list !=NULL)
 
void del_menutrans_vars (void)
 Delete all "menutrans_" variables. More...
 
char * cat_prefix_varname (int prefix, const char *name) FUNC_ATTR_NONNULL_ALL
 Function to concatenate a prefix and a variable name. More...
 
char * get_user_var_name (expand_T *xp, int idx)
 
int pattern_match (char *pat, char *text, bool ic)
 
 if (!evaluate)
 
 xfree (s)
 
 if (rettv->v_type==VAR_UNKNOWN &&!evaluate &&**arg=='(')
 
 if (evaluate &&aborting())
 
int eval0 (char *arg, typval_T *rettv, char **nextcmd, int evaluate)
 
int eval1 (char **arg, typval_T *rettv, int evaluate)
 
 if (evaluate)
 
int get_option_tv (const char **const arg, typval_T *const rettv, const bool evaluate) FUNC_ATTR_NONNULL_ARG(1)
 
char * partial_name (partial_T *pt) FUNC_ATTR_PURE
 
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
 
size_t string2float (const char *const text, float_T *const ret_value) FUNC_ATTR_NONNULL_ALL
 
void get_arglist_as_rettv (aentry_T *arglist, int argcount, typval_T *rettv)
 Get the argument list for a given window. More...
 
void assert_error (garray_T *gap)
 Add an assert error to v:errors. More...
 
win_Tfind_win_by_nr_or_id (typval_T *vp)
 
void filter_map (typval_T *argvars, typval_T *rettv, int map)
 Implementation of map() and filter(). More...
 
 tv_copy (tv, &vimvars[VV_VAL].vv_tv)
 
 if (eval_expr_typval(expr, argv, 2, &rettv)==FAIL)
 
 if (map)
 
 if (error)
 
void common_function (typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr fptr)
 
dict_Tget_buffer_info (buf_T *buf)
 
linenr_T tv_get_lnum_buf (const typval_T *const tv, const buf_T *const buf) FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
 
void get_qf_loc_list (int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv)
 
dict_Tget_tabpage_info (tabpage_T *tp, int tp_idx)
 
dict_Tget_win_info (win_T *wp, int16_t tpnr, int16_t winnr)
 
win_Tfind_win_by_nr (typval_T *vp, tabpage_T *tp)
 
win_Tfind_tabwin (typval_T *wvp, typval_T *tvp)
 Find window specified by "wvp" in tabpage "tvp". More...
 
void getwinvar (typval_T *argvars, typval_T *rettv, int off)
 
void get_user_input (const typval_T *const argvars, typval_T *const rettv, const bool inputdialog, const bool secret) FUNC_ATTR_NONNULL_ALL
 
void dict_list (typval_T *const tv, typval_T *const rettv, const DictListType what)
 
char ** tv_to_argv (typval_T *cmd_tv, const char **cmd, bool *executable)
 
void return_register (int regname, typval_T *rettv)
 
void screenchar_adjust (ScreenGrid **grid, int *row, int *col)
 
void set_buffer_lines (buf_T *buf, linenr_T lnum_arg, bool append, const typval_T *lines, typval_T *rettv) FUNC_ATTR_NONNULL_ARG(4
 Set line or list of lines in buffer "buf". More...
 
 if (buf==NULL||(!is_curbuf &&buf->b_ml.ml_mfp==NULL)||lnum< 1)
 
 if (append)
 
 if (lines->v_type==VAR_LIST)
 
 for (;;)
 
 if (added > 0)
 
void setwinvar (typval_T *argvars, typval_T *rettv, int off)
 
void get_xdg_var_list (const XDGVarType xdg, typval_T *rettv) FUNC_ATTR_NONNULL_ALL
 "stdpath()" helper for list results More...
 
void get_system_output_as_rettv (typval_T *argvars, typval_T *rettv, bool retlist)
 os_system wrapper. Handles 'verbose', :profile, and v:shell_error. More...
 
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
 
timer_Tfind_timer_by_nr (varnumber_T xx)
 
void add_timer_info (typval_T *rettv, timer_T *timer)
 
void add_timer_info_all (typval_T *rettv)
 
void timer_due_cb (TimeWatcher *tw, void *data)
 invoked on the main loop More...
 
uint64_t timer_start (const long timeout, const int repeat_count, const Callback *const callback)
 
void timer_stop (timer_T *timer)
 
void timer_stop_all (void)
 
void timer_teardown (void)
 
bool write_list (FileDescriptor *const fp, const list_T *const list, const bool binary) FUNC_ATTR_NONNULL_ARG(1)
 
bool write_blob (FileDescriptor *const fp, const blob_T *const blob) FUNC_ATTR_NONNULL_ARG(1)
 
bool read_blob (FILE *const fd, blob_T *const blob) FUNC_ATTR_NONNULL_ALL
 
char * save_tv_as_string (typval_T *tv, ptrdiff_t *const len, bool endnl) FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
 
int buf_byteidx_to_charidx (buf_T *buf, linenr_T lnum, int byteidx)
 
int buf_charidx_to_byteidx (buf_T *buf, linenr_T lnum, int charidx)
 
pos_Tvar2fpos (const typval_T *const tv, const bool dollar_lnum, int *const ret_fnum, const bool charcol) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
int list2fpos (typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp, bool charcol)
 
int get_id_len (const char **const arg)
 
int get_name_len (const char **const arg, char **alias, bool evaluate, bool verbose)
 
const char * find_name_end (const char *arg, const char **expr_start, const char **expr_end, int flags)
 
int eval_isnamec (int c)
 
int eval_isnamec1 (int c)
 
typval_Tget_vim_var_tv (int idx)
 Get typval_T v: variable value. More...
 
varnumber_T get_vim_var_nr (int idx) FUNC_ATTR_PURE
 Get number v: variable value. More...
 
char * get_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)
 Set v:char to character "c". More...
 
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_bool (const VimVarIndex idx, const BoolVarValue 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_argv_var (char **argv, int argc)
 Set the v:argv list. More...
 
void set_reg_var (int c)
 Set v:register if needed. More...
 
char * v_exception (char *oldval)
 
char * v_throwpoint (char *oldval)
 
char * set_cmdarg (exarg_T *eap, char *oldarg)
 
int get_var_tv (const char *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload)
 
bool is_luafunc (partial_T *partial) FUNC_ATTR_PURE
 check if special v:lua value for calling lua functions More...
 
const char * skip_luafunc_name (const char *p) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
int check_luafunc_name (const char *const str, const bool paren) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 check the function name after "v:lua." More...
 
int handle_subscript (const char **const arg, typval_T *rettv, int evaluate, int verbose, const char *const start_leader, const char **const end_leaderp)
 
void set_selfdict (typval_T *const rettv, dict_T *const selfdict)
 
dictitem_Tfind_var (const char *const name, const size_t name_len, hashtab_T **htp, int no_autoload)
 
dictitem_Tfind_var_in_ht (hashtab_T *const ht, int htname, const char *const varname, const size_t varname_len, int no_autoload) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
hashtab_Tfind_var_ht (const char *name, const size_t name_len, const char **varname)
 
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, ScopeType scope)
 
void unref_var_dict (dict_T *dict)
 Unreference a dictionary initialized by init_var_dict(). More...
 
void vars_clear (hashtab_T *ht)
 
void vars_clear_ext (hashtab_T *ht, int free_val)
 Like vars_clear(), but only free the value if "free_val" is TRUE. More...
 
void set_var (const char *name, const size_t name_len, typval_T *const tv, const bool copy) FUNC_ATTR_NONNULL_ALL
 
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_fixed (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)
 ":echohl {name}". More...
 
void ex_execute (exarg_T *eap)
 
void func_do_profile (ufunc_T *fp)
 Start profiling function "fp". More...
 
void func_dump_profile (FILE *fd)
 Dump the profiling results for all functions in file "fd". More...
 
char * autoload_name (const char *const name, const size_t name_len) FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT
 
bool script_autoload (const char *const name, const size_t name_len, const bool reload)
 
void func_line_start (void *cookie)
 
void func_line_exec (void *cookie)
 Called when actually executing a function line. More...
 
void func_line_end (void *cookie)
 Called when done with a function line. More...
 
const voidvar_shada_iter (const void *const iter, const char **const name, typval_T *rettv, var_flavour_T flavour) 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 (sctx_T script_ctx)
 
void option_last_set_msg (LastSet last_set)
 
void reset_v_option_vars (void)
 
int modify_fname (char *src, bool tilde_file, size_t *usedlen, char **fnamep, char **bufp, size_t *fnamelen)
 
char * do_string_sub (char *str, char *pat, char *sub, typval_T *expr, char *flags)
 
bool common_job_callbacks (dict_T *vopts, CallbackReader *on_stdout, CallbackReader *on_stderr, Callback *on_exit)
 
Channelfind_job (uint64_t id, bool show_error)
 
void script_host_eval (char *name, typval_T *argvars, typval_T *rettv)
 
typval_T eval_call_provider (char *provider, char *method, list_T *arguments, bool discard)
 
bool eval_has_provider (const char *feat)
 Checks if provider for feature feat is enabled. More...
 
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...
 
void invoke_prompt_callback (void)
 
bool invoke_prompt_interrupt (void)
 
int typval_compare (typval_T *typ1, typval_T *typ2, exprtype_T type, bool ic) FUNC_ATTR_NONNULL_ALL
 
char * typval_tostring (typval_T *arg)
 
bool var_exists (const char *var) FUNC_ATTR_NONNULL_ALL
 

Variables

booleval_lavars_used = NULL
 Used for checking if local variables or arguments used in a lambda. More...
 
const list_Teval_msgpack_type_lists []
 Array mapping values from MessagePackType to corresponding list pointers. More...
 
static int const int did_emsg_before = did_emsg
 
const int called_emsg_before = called_emsg
 
const int ret = eval1(arg, rettv, evaluate)
 
 else
 
char * s = (char *)tv_get_string_buf_chk(expr, buf)
 
return OK
 
const bool res = (tv_get_number_chk(&rettv, error) != 0)
 
tv_clearrettv
 
static char FUNC_ATTR_WARN_UNUSED_RESULT
 
int len = get_env_len((const char **)&arg)
 
int opt_flags
 
char * tofree = NULL
 
if arg
 
char * name = arg
 
char typval_T var1
 
typval_T var2
 
int empty1 = FALSE
 
listitem_Tni
 
hashtab_Tht = NULL
 
int quiet = flags & GLV_QUIET
 
char * expr_start
 
char * expr_end
 
char * p
 
lp ll_name_len = (size_t)((const char *)p - lp->ll_name)
 
 v
 
lp ll_tv = &v->di_tv
 
var1 v_type = VAR_UNKNOWN
 
partial_Tpartial = partial
 
funcexe_T funcexe = FUNCEXE_INIT
 
funcexe firstline = curwin->w_cursor.lnum
 
funcexe lastline = curwin->w_cursor.lnum
 
funcexe evaluate = evaluate
 
funcexe basetv = basetv
 
static int typval_T functv
 
const char * funcname
 
bool is_lua = false
 
funcexe selfdict = selfdict
 
static int typval_T argv [3]
 
int retval = FAIL
 
remp = (tv_get_number_chk(&rettv, &error) == 0)
 
theend __pad0__
 
void const char * line = NULL
 
list_Tl = NULL
 
listitem_Tli = NULL
 
long added = 0
 
linenr_T append_lnum
 
buf_Tcurbuf_save = NULL
 
win_Tcurwin_save = NULL
 
const bool is_curbuf = buf == curbuf
 
const bool save_VIsual_active = VIsual_active
 
 recurse
 
const void const hashitem_Thifirst = globvarht.ht_array
 
const size_t hinum = (size_t)globvarht.ht_mask + 1
 
return NULL
 

Macro Definition Documentation

◆ ABORTING

#define ABORTING (   func)    abort = abort || func

◆ DICT_MAXNEST

#define DICT_MAXNEST   100

◆ SCRIPT_SV

#define SCRIPT_SV (   id)    (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])

◆ SCRIPT_VARS

#define SCRIPT_VARS (   id)    (SCRIPT_SV(id)->sv_dict.dv_hashtab)

◆ VIMVAR_KEY_LEN

#define VIMVAR_KEY_LEN   16

◆ vimvarht

#define vimvarht   vimvardict.dv_hashtab

v: hashtab

◆ VV

#define VV (   idx,
  name,
  type,
  flags 
)
Value:
[idx] = { \
.vv_name = (name), \
.vv_di = { \
.di_tv = { .v_type = (type) }, \
.di_flags = 0, \
.di_key = { 0 }, \
}, \
.vv_flags = (flags), \
}

◆ vv_blob

#define vv_blob   vv_di.di_tv.vval.v_blob

◆ vv_bool

#define vv_bool   vv_di.di_tv.vval.v_bool

◆ VV_COMPAT

#define VV_COMPAT   1

◆ vv_dict

#define vv_dict   vv_di.di_tv.vval.v_dict

◆ vv_float

#define vv_float   vv_di.di_tv.vval.v_float

◆ vv_list

#define vv_list   vv_di.di_tv.vval.v_list

◆ vv_nr

#define vv_nr   vv_di.di_tv.vval.v_number

◆ vv_partial

#define vv_partial   vv_di.di_tv.vval.v_partial

◆ VV_RO

#define VV_RO   2

◆ VV_RO_SBX

#define VV_RO_SBX   4

◆ vv_special

#define vv_special   vv_di.di_tv.vval.v_special

◆ vv_str

#define vv_str   vv_di.di_tv.vval.v_string

◆ vv_tv

#define vv_tv   vv_di.di_tv

◆ vv_type

#define vv_type   vv_di.di_tv.v_type

Function Documentation

◆ add_timer_info()

void add_timer_info ( typval_T rettv,
timer_T timer 
)

◆ add_timer_info_all()

void add_timer_info_all ( typval_T rettv)

◆ assert_error()

void assert_error ( garray_T gap)

Add an assert error to v:errors.

◆ autoload_name()

char* autoload_name ( const char *const  name,
const size_t  name_len 
)

Return the autoload script name for a function or variable name Caller must make sure that "name" contains AUTOLOAD_CHAR.

Parameters
[in]nameVariable/function name.
[in]name_lenName length.
Returns
[allocated] autoload script name.

◆ buf_byteidx_to_charidx()

int buf_byteidx_to_charidx ( buf_T buf,
linenr_T  lnum,
int  byteidx 
)

Convert the specified byte index of line 'lnum' in buffer 'buf' to a character index. Works only for loaded buffers. Returns -1 on failure. The index of the first byte and the first character is zero.

◆ buf_charidx_to_byteidx()

int buf_charidx_to_byteidx ( buf_T buf,
linenr_T  lnum,
int  charidx 
)

Convert the specified character index of line 'lnum' in buffer 'buf' to a byte index. Works only for loaded buffers. The index of the first byte and the first character is zero.

Returns
-1 on failure.

◆ call_func_retlist()

void* call_func_retlist ( const char *  func,
int  argc,
typval_T argv 
)

Call Vim script function and return the result as a List

Parameters
[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with typval_T arguments.
Returns
[allocated] NULL when calling function fails or return tv is not a List, allocated List otherwise.

◆ call_func_retnr()

varnumber_T call_func_retnr ( const char *  func,
int  argc,
typval_T argv 
)

Call Vim script function and return the result as a number

Parameters
[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with typval_T arguments.
Returns
-1 when calling function fails, result of function otherwise.

◆ call_func_retstr()

char* call_func_retstr ( const char *const  func,
int  argc,
typval_T argv 
)

Call Vim script function and return the result as a string

Parameters
[in]funcFunction name.
[in]argcNumber of arguments.
[in]argvArray with typval_T arguments.
Returns
[allocated] NULL when calling function fails, allocated string otherwise.

◆ call_vim_function()

int call_vim_function ( const char *  func,
int  argc,
typval_T argv,
typval_T rettv 
)

◆ callback_call()

bool callback_call ( Callback *const  callback,
const int  argcount_in,
typval_T *const  argvars_in,
typval_T *const  rettv 
)

◆ callback_from_typval()

bool callback_from_typval ( Callback *const  callback,
typval_T *const  arg 
)

◆ cat_prefix_varname()

char* cat_prefix_varname ( int  prefix,
const char *  name 
)

Function to concatenate a prefix and a variable name.

◆ check_luafunc_name()

int check_luafunc_name ( const char *const  str,
const bool  paren 
)

check the function name after "v:lua."

◆ clear_lval()

void clear_lval ( lval_T lp)

Clear lval "lp" that was filled by get_lval().

◆ common_function()

void common_function ( typval_T argvars,
typval_T rettv,
bool  is_funcref,
FunPtr  fptr 
)

◆ common_job_callbacks()

bool common_job_callbacks ( dict_T vopts,
CallbackReader on_stdout,
CallbackReader on_stderr,
Callback on_exit 
)

common code for getting job callbacks for jobstart, termopen and rpcstart

Returns
true/false on success/failure.

◆ del_menutrans_vars()

void del_menutrans_vars ( void  )

Delete all "menutrans_" variables.

◆ dict_list()

void dict_list ( typval_T *const  tv,
typval_T *const  rettv,
const DictListType  what 
)

Turn a dictionary into a list

Parameters
[in]tvDictionary to convert. Is checked for actually being a dictionary, will give an error if not.
[out]rettvLocation where result will be saved.
[in]whatWhat to save in rettv.

◆ do_string_sub()

char* do_string_sub ( char *  str,
char *  pat,
char *  sub,
typval_T expr,
char *  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.

◆ do_unlet()

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

unlet a variable

Parameters
[in]nameVariable name to unlet.
[in]name_lenVariable name length.
[in]forceitIf true, do not complain if variable doesn’t exist.
Returns
OK if it existed, FAIL otherwise.

◆ eval0()

int eval0 ( char *  arg,
typval_T rettv,
char **  nextcmd,
int  evaluate 
)

Handle zero level expression. This calls eval1() and handles error message and nextcmd. Put the result in "rettv" when returning OK and "evaluate" is TRUE. Note: "rettv.v_lock" is not set.

Returns
OK or FAIL.

◆ eval1()

int eval1 ( char **  arg,
typval_T rettv,
int  evaluate 
)

Handle top level expression: expr2 ? expr1 : expr1

"arg" must point to the first non-white of the expression. "arg" is advanced to the next non-white after the recognized expression.

Note: "rettv.v_lock" is not set.

Returns
OK or FAIL.

◆ eval_call_provider()

typval_T eval_call_provider ( char *  provider,
char *  method,
list_T arguments,
bool  discard 
)
Parameters
discardClears the value returned by the provider and returns an empty typval_T.

◆ eval_charconvert()

int eval_charconvert ( const char *const  enc_from,
const char *const  enc_to,
const char *const  fname_from,
const char *const  fname_to 
)

◆ eval_diff()

void eval_diff ( const char *const  origfile,
const char *const  newfile,
const char *const  outfile 
)

◆ eval_expr()

typval_T* eval_expr ( char *  arg)

Top level evaluation function.

Returns
an allocated typval_T with the result or NULL when there is an error.

◆ eval_expr_to_bool()

bool eval_expr_to_bool ( const typval_T expr,
bool error 
)

Like eval_to_bool() but using a typval_T instead of a string. Works for string, funcref and partial.

◆ eval_expr_typval()

int eval_expr_typval ( const typval_T expr,
typval_T argv,
int  argc,
typval_T rettv 
)

◆ eval_expr_valid_arg()

bool eval_expr_valid_arg ( const typval_T *const  tv)
Returns
whether a typval is a valid expression to pass to eval_expr_typval() or eval_expr_to_bool(). An empty string returns false;

◆ eval_fmt_source_name_line()

void eval_fmt_source_name_line ( char *  buf,
size_t  bufsize 
)

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

◆ eval_foldexpr()

int eval_foldexpr ( char *  arg,
int *  cp 
)

Evaluate 'foldexpr'. Returns the foldlevel, and any character preceding it in "*cp". Doesn't give error messages.

◆ eval_for_line()

void* eval_for_line ( const char *  arg,
bool errp,
char **  nextcmdp,
int  skip 
)

Evaluate the expression used in a ":for var in expr" command. "arg" points to "var".

Parameters
[out]*errpset to TRUE for an error, FALSE otherwise;
Returns
a pointer that holds the info. Null when there is an error.

◆ eval_has_provider()

bool eval_has_provider ( const char *  feat)

Checks if provider for feature feat is enabled.

◆ eval_init()

void eval_init ( void  )

Initialize the global and v: variables.

◆ eval_isnamec()

int eval_isnamec ( int  c)
Returns
TRUE if character "c" can be used in a variable or function name. Does not include '{' or '}' for magic braces.

◆ eval_isnamec1()

int eval_isnamec1 ( int  c)
Returns
TRUE if character "c" can be used as the first character in a variable or function name (excluding '{' and '}').

◆ eval_patch()

void eval_patch ( const char *const  origfile,
const char *const  difffile,
const char *const  outfile 
)

◆ eval_printexpr()

int eval_printexpr ( const char *const  fname,
const char *const  args 
)

◆ eval_spell_expr()

list_T* eval_spell_expr ( char *  badword,
char *  expr 
)

Evaluate an expression to a list with suggestions. For the "expr:" part of 'spellsuggest'.

Returns
NULL when there is an error.

◆ eval_to_bool()

int eval_to_bool ( char *  arg,
bool error,
char **  nextcmd,
int  skip 
)

Top level evaluation function, returning a boolean. Sets "error" to TRUE if there was an error.

Parameters
skiponly parse, don't execute
Returns
TRUE or FALSE.

◆ eval_to_number()

varnumber_T eval_to_number ( char *  expr)

Top level evaluation function, returning a number. Evaluates "expr" silently.

Returns
-1 for an error.

◆ eval_to_string()

char* eval_to_string ( char *  arg,
char **  nextcmd,
bool  convert 
)

Top level evaluation function, returning a string.

Parameters
convertwhen true convert a List into a sequence of lines and convert a Float to a String.
Returns
pointer to allocated memory, or NULL for failure.

◆ eval_to_string_safe()

char* eval_to_string_safe ( char *  arg,
char **  nextcmd,
int  use_sandbox 
)

Call eval_to_string() without using current local variables and using textlock.

Parameters
use_sandboxwhen TRUE, use the sandbox.

◆ eval_to_string_skip()

char* eval_to_string_skip ( const char *  arg,
const char **  nextcmd,
const bool  skip 
)

Top level evaluation function, returning a string

Parameters
[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.
Returns
[allocated] string result of evaluation or NULL in case of error or when skipping.

◆ ex_checkhealth()

void ex_checkhealth ( exarg_T eap)

":checkhealth [plugins]"

◆ ex_const()

void ex_const ( exarg_T eap)

":cons[t] var = expr1" define constant ":cons[t] [name1, name2, ...] = expr1" define constants unpacking list ":cons[t] [name, ..., ; lastname] = expr" define constants unpacking list

◆ ex_echo()

void ex_echo ( exarg_T eap)

":echo expr1 ..." print each argument separated with a space, add a newline at the end. ":echon expr1 ..." print each argument plain.

◆ ex_echohl()

void ex_echohl ( exarg_T eap)

":echohl {name}".

◆ ex_execute()

void ex_execute ( exarg_T eap)

":execute expr1 ..." execute the result of an expression. ":echomsg expr1 ..." Print a message ":echoerr expr1 ..." Print an error Each gets spaces around each argument and a newline at the end for echo commands

◆ ex_let()

void ex_let ( exarg_T eap)

":let" list all variable values ":let var1 var2" list variable values ":let var = expr" assignment command. ":let var += expr" assignment command. ":let var -= expr" assignment command. ":let var *= expr" assignment command. ":let var /= expr" assignment command. ":let var %= expr" assignment command. ":let var .= expr" assignment command. ":let var ..= expr" assignment command. ":let [var1, var2] = expr" unpack list. ":let [name, ..., ; lastname] = expr" unpack list.

◆ ex_lockvar()

void ex_lockvar ( exarg_T eap)

":lockvar" and ":unlockvar" commands

◆ ex_unlet()

void ex_unlet ( exarg_T eap)

":unlet[!] var1 ... " command.

◆ filter_map()

void filter_map ( typval_T argvars,
typval_T rettv,
int  map 
)

Implementation of map() and filter().

◆ find_job()

Channel* find_job ( uint64_t  id,
bool  show_error 
)

◆ find_name_end()

const char* find_name_end ( const char *  arg,
const char **  expr_start,
const char **  expr_end,
int  flags 
)

Find the end of a variable or function name, taking care of magic braces.

Parameters
expr_startif not NULL, then expr_start and expr_end are set to the start and end of the first magic braces item.
flagscan have FNE_INCL_BR and FNE_CHECK_START.
Returns
a pointer to just after the name. Equal to "arg" if there is no valid name.

◆ find_tabwin()

win_T* find_tabwin ( typval_T wvp,
typval_T tvp 
)

Find window specified by "wvp" in tabpage "tvp".

◆ find_timer_by_nr()

timer_T* find_timer_by_nr ( varnumber_T  xx)

◆ find_var()

dictitem_T* find_var ( const char *const  name,
const size_t  name_len,
hashtab_T **  htp,
int  no_autoload 
)

Find variable "name" in the list of variables. Careful: "a:0" variables don't have a name. When "htp" is not NULL we are writing to the variable, set "htp" to the hashtab_T used.

Returns
a pointer to it if found, NULL if not found.

◆ find_var_ht()

hashtab_T* find_var_ht ( const char *  name,
const size_t  name_len,
const char **  varname 
)

Find the hashtable used for a variable

Parameters
[in]nameVariable name, possibly with scope prefix.
[in]name_lenVariable name length.
[out]varnameWill be set to the start of the name without scope prefix.
Returns
Scope hashtab, NULL if name is not valid.

◆ find_var_in_ht()

dictitem_T* find_var_in_ht ( hashtab_T *const  ht,
int  htname,
const char *const  varname,
const size_t  varname_len,
int  no_autoload 
)

Find variable in hashtab. When "varname" is empty returns curwin/curtab/etc vars dictionary.

Parameters
[in]htHashtab to find variable in.
[in]htnameHashtab name (first character).
[in]varnameVariable name.
[in]varname_lenVariable name length.
[in]no_autoloadIf true then autoload scripts will not be sourced if autoload variable was not found.
Returns
pointer to the dictionary item with the found variable or NULL if it was not found.

◆ find_win_by_nr()

win_T* find_win_by_nr ( typval_T vp,
tabpage_T tp 
)

Find window specified by "vp" in tabpage "tp".

Parameters
tpNULL for current tab page

◆ find_win_by_nr_or_id()

win_T* find_win_by_nr_or_id ( typval_T vp)

Find a window: When using a Window ID in any tab page, when using a number in the current tab page.

◆ find_win_for_curbuf()

void find_win_for_curbuf ( void  )

If there is a window for "curbuf", make it the current window.

◆ for()

for ( ;;  )

◆ free_for_info()

void free_for_info ( void fi_void)

Free the structure used to store info used by ":for".

◆ func_do_profile()

void func_do_profile ( ufunc_T fp)

Start profiling function "fp".

◆ func_dump_profile()

void func_dump_profile ( FILE *  fd)

Dump the profiling results for all functions in file "fd".

◆ func_equal()

bool func_equal ( typval_T tv1,
typval_T tv2,
bool  ic 
)
Parameters
icignore case

◆ func_line_end()

void func_line_end ( void cookie)

Called when done with a function line.

◆ func_line_exec()

void func_line_exec ( void cookie)

Called when actually executing a function line.

◆ func_line_start()

void func_line_start ( void cookie)

Called when starting to read a function line. "sourcing_lnum" must be correct! When skipping lines it may not actually be executed, but we won't find out until later and we need to store the time now.

◆ garbage_collect()

bool garbage_collect ( bool  testing)

Do garbage collection for lists and dicts.

Parameters
testingtrue if called from test_garbagecollect_now().
Returns
true if some memory was freed.

◆ get_arglist_as_rettv()

void get_arglist_as_rettv ( aentry_T arglist,
int  argcount,
typval_T rettv 
)

Get the argument list for a given window.

◆ get_buffer_info()

dict_T* get_buffer_info ( buf_T buf)
Returns
buffer options, variables and other attributes in a dictionary.

◆ get_copyID()

int get_copyID ( void  )

Get next (unique) copy ID

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

◆ get_id_len()

int get_id_len ( const char **const  arg)

Get the length of the name of a function or internal variable.

Parameters
argis advanced to the first non-white character after the name.
Returns
0 if something is wrong.

◆ get_lval()

char* get_lval ( char *const  name,
typval_T *const  rettv,
lval_T *const  lp,
const bool  unlet,
const bool  skip,
const int  flags,
const int  fne_flags 
)

Get an lvalue

Lvalue may be

  • variable: "name", "na{me}"
  • dictionary item: "dict.key", "dict['key']"
  • list item: "list[expr]"
  • list slice: "list[expr:expr]"

Indexing only works if trying to use it with an existing List or Dictionary.

Parameters
[in]nameName to parse.
rettvPointer to the value to be assigned or NULL.
[out]lpLvalue definition. When evaluation errors occur ->ll_name is NULL.
[in]unletTrue if using :unlet. This results in slightly different behaviour when something is wrong; must end in space or cmd separator.
[in]skipTrue when skipping.
[in]flags
See also
GetLvalFlags.
Parameters
[in]fne_flagsFlags for find_name_end().
Returns
A pointer to just after the name, including indexes. Returns NULL for a parsing error, but it is still needed to free items in lp.

◆ get_name_len()

int get_name_len ( const char **const  arg,
char **  alias,
bool  evaluate,
bool  verbose 
)

Get the length of the name of a variable or function. Only the name is recognized, does not handle ".key" or "[idx]".

Parameters
argis advanced to the first non-white character after the name. If the name contains 'magic' {}'s, expand them and return the expanded name in an allocated string via 'alias' - caller must free.
Returns
-1 if curly braces expansion failed or 0 if something else is wrong.

◆ get_option_tv()

int get_option_tv ( const char **const  arg,
typval_T *const  rettv,
const bool  evaluate 
)

Get an option value

Parameters
[in,out]argPoints to the '&' or '+' before the option name. Is advanced to the character after the option name.
[out]rettvLocation where result is saved.
[in]evaluateIf not true, rettv is not populated.
Returns
OK or FAIL.

◆ get_qf_loc_list()

void get_qf_loc_list ( int  is_qf,
win_T wp,
typval_T what_arg,
typval_T rettv 
)

◆ get_spellword()

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.

Parameters
[in]listList to get values from.
[out]ret_wordSuggested word. Not initialized if return value is -1.
Returns
-1 in case of error, score otherwise.

◆ get_system_output_as_rettv()

void get_system_output_as_rettv ( typval_T argvars,
typval_T rettv,
bool  retlist 
)

os_system wrapper. Handles 'verbose', :profile, and v:shell_error.

◆ get_tabpage_info()

dict_T* get_tabpage_info ( tabpage_T tp,
int  tp_idx 
)
Returns
information (variables, options, etc.) about a tab page as a dictionary.

◆ get_user_input()

void get_user_input ( const typval_T *const  argvars,
typval_T *const  rettv,
const bool  inputdialog,
const bool  secret 
)

This function is used by f_input() and f_inputdialog() functions. The third argument to f_input() specifies the type of completion to use at the prompt. The third argument to f_inputdialog() specifies the value to return when the user cancels the prompt.

◆ get_user_var_name()

char* get_user_var_name ( expand_T xp,
int  idx 
)

Function given to ExpandGeneric() to obtain the list of user defined (global/buffer/window/built-in) variable names.

◆ get_v_event()

dict_T* get_v_event ( save_v_event_T sve)

◆ get_var_tv()

int get_var_tv ( const char *  name,
int  len,
typval_T rettv,
dictitem_T **  dip,
int  verbose,
int  no_autoload 
)

Get the value of internal variable "name". Return OK or FAIL. If OK is returned "rettv" must be cleared.

Parameters
lenlength of "name"
rettvNULL when only checking existence
dipnon-NULL when typval's dict item is needed
verbosemay give error message
no_autoloaddo not use script autoloading

◆ get_var_value()

char_u* get_var_value ( const char *const  name)
Returns
the string value of a (global/local) variable or NULL when it doesn't exist.
See also
tv_get_string() for how long the pointer remains valid.

◆ get_vim_var_dict()

dict_T* get_vim_var_dict ( int  idx)

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

◆ get_vim_var_list()

list_T* get_vim_var_list ( int  idx)

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

◆ get_vim_var_nr()

varnumber_T get_vim_var_nr ( int  idx)

Get number v: variable value.

◆ get_vim_var_str()

char* get_vim_var_str ( int  idx)

Get string v: variable value. Uses a static buffer, can only be used once. If the String variable has never been set, return an empty string. Never returns NULL.

◆ get_vim_var_tv()

typval_T* get_vim_var_tv ( int  idx)

Get typval_T v: variable value.

◆ get_win_info()

dict_T* get_win_info ( win_T wp,
int16_t  tpnr,
int16_t  winnr 
)
Returns
information about a window as a dictionary.

◆ get_xdg_var_list()

void get_xdg_var_list ( const XDGVarType  xdg,
typval_T rettv 
)

"stdpath()" helper for list results

◆ getwinvar()

void getwinvar ( typval_T argvars,
typval_T rettv,
int  off 
)

getwinvar() and gettabwinvar()

Parameters
off1 for gettabwinvar()

◆ handle_subscript()

int handle_subscript ( const char **const  arg,
typval_T rettv,
int  evaluate,
int  verbose,
const char *const  start_leader,
const char **const  end_leaderp 
)

Handle:

  • expr[expr], expr[expr:expr] subscript
  • ".name" lookup
  • function call with Funcref variable: func(expr)
  • method call: var->method()

Can all be combined in any order: dict.func(expr)[idx]['func'](expr)->len()

Parameters
evaluatedo more than finding the end
verbosegive error messages
start_leaderstart of '!' and '-' prefixes
end_leaderpend of '!' and '-' prefixes

◆ if() [1/26]

if ( evaluate)

◆ if() [2/26]

if ( *!='[' &&*!='. 'p||lp->  ll_name = NULL)

◆ if() [3/26]

if ( added  ,
 
)

◆ if() [4/26]

if ( append  )

◆ if() [5/26]

if ( )

◆ if() [6/26]

if ( deep  = = 0)

◆ if() [7/26]

if ( error  )

◆ if() [8/26]

if ( eval1_emsg &,,  true = FAIL)

◆ if() [9/26]

bool if ( eval_expr_typval(expr, &argv, 0, &rettv = FAIL)

◆ if() [10/26]

if ( eval_expr_typval(expr, argv, 2, &rettv = FAIL)

◆ if() [11/26]

if ( evaluate &&  aborting())

◆ if() [12/26]

if ( evaluate  )

◆ if() [13/26]

else if ( expr->  v_type = VAR_FUNC)

◆ if() [14/26]

if ( expr_start = NULL)

◆ if() [15/26]

if ( iter  = NULL)

◆ if() [16/26]

if ( len  = = 0)

◆ if() [17/26]

if ( lines->  v_type = VAR_LIST)

◆ if() [18/26]

else if ( lp->ll_list !  = NULL)

◆ if() [19/26]

else if ( lp->  ll_tv = NULL)

◆ if() [20/26]

if ( map  )

◆ if() [21/26]

if ( recurse >=  DICT_MAXNEST)

◆ if() [22/26]

if ( ret  = FAIL)

◆ if() [23/26]

if ( rettv->  v_type = VAR_UNKNOWN && !evaluate && **arg == '(')

◆ if() [24/26]

if ( s  = NULL)

◆ if() [25/26]

if ( skip  )

◆ if() [26/26]

if ( v  = NULL && !quiet)

◆ init_var_dict()

void init_var_dict ( dict_T dict,
ScopeDictDictItem *  dict_var,
ScopeType  scope 
)

Initialize dictionary "dict" as a scope and set variable "dict_var" to point to it.

◆ invoke_prompt_callback()

void invoke_prompt_callback ( void  )

◆ invoke_prompt_interrupt()

bool invoke_prompt_interrupt ( void  )
Returns
true when the interrupt callback was invoked.

◆ is_luafunc()

bool is_luafunc ( partial_T partial)

check if special v:lua value for calling lua functions

◆ last_set_msg()

void last_set_msg ( sctx_T  script_ctx)

Display script name where an item was last set. Should only be invoked when 'verbose' is non-zero.

◆ list2fpos()

int list2fpos ( typval_T arg,
pos_T posp,
int *  fnump,
colnr_T curswantp,
bool  charcol 
)

Convert list in "arg" into a position and optional file number. When "fnump" is NULL there is no file number, only 3 items. Note that the column is passed on as-is, the caller may want to decrement it to use 1 for the first column.

Returns
FAIL when conversion is not possible, doesn't check the position for validity.

◆ list_hashtable_vars()

void list_hashtable_vars ( hashtab_T ht,
const char *  prefix,
int  empty,
int *  first 
)

List variables for hashtab "ht" with prefix "prefix".

Parameters
emptyif TRUE also list NULL strings as empty strings.

◆ memset()

memset ( lp  ,
,
sizeof(lval_T  
)

◆ modify_fname()

int modify_fname ( char *  src,
bool  tilde_file,
size_t *  usedlen,
char **  fnamep,
char **  bufp,
size_t *  fnamelen 
)

Adjust a filename, according to a string of modifiers. *fnamep must be NUL terminated when called. When returning, the length is determined by *fnamelen. Returns VALID_ flags or -1 for failure. When there is an error, *fnamep is set to NULL.

Parameters
srcstring with modifiers
tilde_file"~" is a file name, not $HOME
usedlencharacters after src that are used
fnamepfile name so far
bufpbuffer for allocated file name or NULL
fnamelenlength of fnamep

◆ new_script_vars()

void new_script_vars ( scid_T  id)

Allocate a new hashtab for a sourced script. It will be used while sourcing this script and when executing functions defined in the script.

◆ next_for_item()

bool next_for_item ( void fi_void,
char *  arg 
)

Use the first item in a ":for" list. Advance to the next. Assign the values to the variable (list). "arg" points to the first one.

Returns
true when a valid item was found, false when at end of list or something wrong.

◆ num_divide()

varnumber_T num_divide ( varnumber_T  n1,
varnumber_T  n2 
)
Returns
"n1" divided by "n2", taking care of dividing by zero.

◆ num_modulus()

varnumber_T num_modulus ( varnumber_T  n1,
varnumber_T  n2 
)
Returns
"n1" modulus "n2", taking care of dividing by zero.

◆ option_last_set_msg()

void option_last_set_msg ( LastSet  last_set)

Displays where an option was last set.

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

◆ p()

while* p ( p = = '.' && lp->ll_tv->v_type == VAR_DICT)

◆ partial_name()

char* partial_name ( partial_T pt)
Returns
the function name of the partial.

◆ partial_unref()

void partial_unref ( partial_T pt)

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

◆ pattern_match()

int pattern_match ( char *  pat,
char *  text,
bool  ic 
)

Does not use 'cpo' and always uses 'magic'.

Returns
TRUE if "pat" matches "text".

◆ prepare_vimvar()

void prepare_vimvar ( int  idx,
typval_T save_tv 
)

Prepare v: variable "idx" to be used. Save the current typeval in "save_tv". When not used yet add the variable to the v: hashtable.

◆ prof_child_enter()

void prof_child_enter ( proftime_T tm)

Prepare profiling for entering a child or something else that is not counted for the script/function itself. Should always be called in pair with prof_child_exit().

Parameters
tmplace to store waittime

◆ prof_child_exit()

void prof_child_exit ( proftime_T tm)

Take care of time spent in a child. Should always be called after prof_child_enter().

Parameters
tmwhere waittime was stored

◆ read_blob()

bool read_blob ( FILE *const  fd,
blob_T *const  blob 
)

Read a blob from a file fd.

Parameters
[in]fdFile to read from.
[in,out]blobBlob to write to.
Returns
true on success, or false on failure.

◆ reset_v_option_vars()

void reset_v_option_vars ( void  )

◆ restore_v_event()

void restore_v_event ( dict_T v_event,
save_v_event_T sve 
)

◆ restore_vimvar()

void restore_vimvar ( int  idx,
typval_T save_tv 
)

Restore v: variable "idx" to typeval "save_tv". When no longer defined, remove the variable from the v: hashtable.

◆ return_register()

void return_register ( int  regname,
typval_T rettv 
)

◆ save_tv_as_string()

char* save_tv_as_string ( typval_T tv,
ptrdiff_t *const  len,
bool  endnl 
)

Saves a typval_T as a string.

For lists or buffers, replaces NLs with NUL and separates items with NLs.

Parameters
[in]tvValue to store as a string.
[out]lenLength of the resulting string or -1 on error.
[in]endnlIf true, the output will end in a newline (if a list).
Returns
an allocated string if tv represents a VimL string, list, or number; NULL otherwise.

◆ screenchar_adjust()

void screenchar_adjust ( ScreenGrid **  grid,
int *  row,
int *  col 
)

◆ script_autoload()

bool script_autoload ( const char *const  name,
const size_t  name_len,
const bool  reload 
)

If name has a package name try autoloading the script for it

Parameters
[in]nameVariable/function name.
[in]name_lenName length.
[in]reloadIf true, load script again when already loaded.
Returns
true if a package was loaded.

◆ script_host_eval()

void script_host_eval ( char *  name,
typval_T argvars,
typval_T rettv 
)

◆ set_argv_var()

void set_argv_var ( char **  argv,
int  argc 
)

Set the v:argv list.

◆ set_buffer_lines()

void set_buffer_lines ( buf_T buf,
linenr_T  lnum_arg,
bool  append,
const typval_T lines,
typval_T rettv 
)

Set line or list of lines in buffer "buf".

◆ set_cmdarg()

char* set_cmdarg ( exarg_T eap,
char *  oldarg 
)

Set v:cmdarg. If "eap" != NULL, use "eap" to generate the value and return the old value. If "oldarg" != NULL, restore the value to "oldarg" and return NULL. Must always be called in pairs!

◆ set_context_for_expression()

void set_context_for_expression ( expand_T xp,
char *  arg,
cmdidx_T  cmdidx 
)

◆ set_internal_string_var()

void set_internal_string_var ( const char *  name,
char *  value 
)

Set an internal variable to a string value. Creates the variable if it does not already exist.

◆ set_ref_in_ht()

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".

Parameters
htHashtab content will be marked.
copyIDNew mark for lists and dicts.
list_stackUsed to add lists to be marked. Can be NULL.
Returns
true if setting references failed somehow.

◆ set_ref_in_item()

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".

Parameters
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.
Returns
true if setting references failed somehow.

◆ set_ref_in_list()

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".

Parameters
lList content will be marked.
copyIDNew mark for lists and dicts.
ht_stackUsed to add hashtabs to be marked. Can be NULL.
Returns
true if setting references failed somehow.

◆ set_reg_var()

void set_reg_var ( int  c)

Set v:register if needed.

◆ set_selfdict()

void set_selfdict ( typval_T *const  rettv,
dict_T *const  selfdict 
)

◆ set_var()

void set_var ( const char *  name,
const size_t  name_len,
typval_T *const  tv,
const bool  copy 
)

Set variable to the given value

If the variable already exists, the value is updated. Otherwise the variable is created.

Parameters
[in]nameVariable name to set.
[in]name_lenLength of the variable name.
tvVariable value.
[in]copyTrue if value in tv is to be copied.

◆ set_vcount()

void set_vcount ( long  count,
long  count1,
int  set_prevcount 
)

Set v:count to "count" and v:count1 to "count1".

Parameters
set_prevcountif TRUE, first set v:prevcount from v:count.

◆ set_vim_var_bool()

void set_vim_var_bool ( const VimVarIndex  idx,
const BoolVarValue  val 
)

Set boolean v: {true, false} to the given value

Parameters
[in]idxIndex of variable to set.
[in]valValue to set to.

◆ set_vim_var_char()

void set_vim_var_char ( int  c)

Set v:char to character "c".

◆ set_vim_var_dict()

void set_vim_var_dict ( const VimVarIndex  idx,
dict_T *const  val 
)

Set Dictionary v: variable to the given dictionary

Parameters
[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.

◆ set_vim_var_list()

void set_vim_var_list ( const VimVarIndex  idx,
list_T *const  val 
)

Set list v: variable to the given list

Parameters
[in]idxIndex of variable to set.
[in,out]valValue to set to. Reference count will be incremented.

◆ set_vim_var_nr()

void set_vim_var_nr ( const VimVarIndex  idx,
const varnumber_T  val 
)

Set number v: variable to the given value

Parameters
[in]idxIndex of variable to set.
[in]valValue to set to.

◆ set_vim_var_special()

void set_vim_var_special ( const VimVarIndex  idx,
const SpecialVarValue  val 
)

Set special v: variable to the given value

Parameters
[in]idxIndex of variable to set.
[in]valValue to set to.

◆ set_vim_var_string()

void set_vim_var_string ( const VimVarIndex  idx,
const char *const  val,
const ptrdiff_t  len 
)

Set string v: variable to the given string

Parameters
[in]idxIndex of variable to set.
[in]valValue to set to. Will be copied.
[in]lenLength of that value or -1 in which case strlen() will be used.

◆ setwinvar()

void setwinvar ( typval_T argvars,
typval_T rettv,
int  off 
)

◆ skip_expr()

int skip_expr ( char **  pp)

Skip over an expression at "*pp".

Returns
FAIL for an error, OK otherwise.

◆ skip_luafunc_name()

const char* skip_luafunc_name ( const char *  p)

Skips one character past the end of the name of a v:lua function.

Parameters
pPointer to the char AFTER the "v:lua." prefix.
Returns
Pointer to the char one past the end of the function's name.

◆ skipwhite()

if* skipwhite ( s  )

◆ store_session_globals()

int store_session_globals ( FILE *  fd)

◆ string2float()

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.

Parameters
[in]textString to convert.
[out]ret_valueLocation where conversion result is saved.
Returns
Length of the text that was consumed.

◆ switch()

switch ( from->  v_type)

◆ timer_due_cb()

void timer_due_cb ( TimeWatcher tw,
void data 
)

invoked on the main loop

◆ timer_start()

uint64_t timer_start ( const long  timeout,
const int  repeat_count,
const Callback *const  callback 
)

◆ timer_stop()

void timer_stop ( timer_T timer)

◆ timer_stop_all()

void timer_stop_all ( void  )

◆ timer_teardown()

void timer_teardown ( void  )

◆ tv_copy()

tv_copy ( tv  ,
&vimvars.  vv_tv[VV_VAL] 
)

◆ TV_DICT_HI2DI()

tv_copy& TV_DICT_HI2DI ( hi  ) -> di_tv, rettv

◆ tv_get_lnum_buf()

linenr_T tv_get_lnum_buf ( const typval_T *const  tv,
const buf_T *const  buf 
)

Get the line number from VimL object

Note
Unlike tv_get_lnum(), this one supports only "$" special string.
Parameters
[in]tvObject to get value from. Is expected to be a number or a special string "$".
[in]bufBuffer to take last line number from in case tv is "$". May be NULL, in this case "$" results in zero return.
Returns
Line number or 0 in case of error.

◆ tv_to_argv()

char** tv_to_argv ( typval_T cmd_tv,
const char **  cmd,
bool executable 
)

Builds a process argument vector from a VimL object (typval_T).

Parameters
[in]cmd_tvVimL object
[out]cmdReturns the command or executable name.
[out]executableReturns false if argv[0] is not executable.
Returns
Result of shell_build_argv() if cmd_tv is a String. Else, string values of cmd_tv copied to a (char **) list with argv[0] resolved to full path ($PATHEXT-resolved on Windows).

◆ typval_compare()

int typval_compare ( typval_T typ1,
typval_T typ2,
exprtype_T  type,
bool  ic 
)

Compare "typ1" and "typ2". Put the result in "typ1".

Parameters
typ1first operand
typ2second operand
typeoperator
icignore case

◆ typval_tostring()

char* typval_tostring ( typval_T arg)

◆ unref_var_dict()

void unref_var_dict ( dict_T dict)

Unreference a dictionary initialized by init_var_dict().

◆ v_exception()

char* v_exception ( char *  oldval)

Get or set v:exception. If "oldval" == NULL, return the current value. Otherwise, restore the value to "oldval" and return NULL. Must always be called in pairs to save and restore v:exception! Does not take care of memory allocations.

◆ v_throwpoint()

char* v_throwpoint ( char *  oldval)

Get or set v:throwpoint. If "oldval" == NULL, return the current value. Otherwise, restore the value to "oldval" and return NULL. Must always be called in pairs to save and restore v:throwpoint! Does not take care of memory allocations.

◆ valid_varname()

bool valid_varname ( const char *  varname)

Check if a variable name is valid

Parameters
[in]varnameVariable name to check.
Returns
false when variable name is not valid, true when it is. Also gives an error message if appropriate.

◆ var2fpos()

pos_T* var2fpos ( const typval_T *const  tv,
const bool  dollar_lnum,
int *const  ret_fnum,
const bool  charcol 
)

Translate a VimL object into a position

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

Parameters
[in]tvObject to translate.
[in]dollar_lnumTrue when "$" is last line.
[out]ret_fnumSet to fnum for marks.
[in]charcolTrue to return character column.
Returns
Pointer to position or NULL in case of error (e.g. invalid type).

◆ var_check_fixed()

bool var_check_fixed ( const int  flags,
const char *  name,
size_t  name_len 
)

Check whether variable is fixed (DI_FLAGS_FIX)

Also gives an error message.

Parameters
[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.

Returns
True if variable is fixed, false otherwise.

◆ var_check_func_name()

bool var_check_func_name ( const char *const  name,
const bool  new_var 
)

Check if name is a valid name to assign funcref to

Parameters
[in]namePossible function/funcref name.
[in]new_varTrue if it is a name for a variable.
Returns
false in case of error, true in case of success. Also gives an error message if appropriate.

◆ var_check_ro()

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.

Parameters
[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.

Returns
True if variable is read-only: either always or in sandbox when sandbox is enabled, false otherwise.

◆ var_exists()

bool var_exists ( const char *  var)

◆ var_item_copy()

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.

Parameters
[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.

◆ var_redir_start()

int var_redir_start ( char *  name,
int  append 
)

Start recording command output to a variable

Parameters
appendappend to an existing variable
Returns
OK if successfully completed the setup. FAIL otherwise.

◆ var_redir_stop()

void var_redir_stop ( void  )

Stop redirecting command output to a variable. Frees the allocated memory.

◆ var_redir_str()

void var_redir_str ( char *  value,
int  value_len 
)

Append "value[value_len]" to the variable set by var_redir_start(). The actual appending is postponed until redirection ends, because the value appended may in fact be the string we write to, changing it may cause freed memory to be used: :redir => foo :let foo :redir END

◆ var_set_global()

void var_set_global ( const char *const  name,
typval_T  vartv 
)

◆ var_shada_iter()

const void* var_shada_iter ( const void *const  iter,
const char **const  name,
typval_T rettv,
var_flavour_T  flavour 
)

Iterate over global variables

Warning
No modifications to global variable dictionary must be performed while iteration is in progress.
Parameters
[in]iterIterator. Pass NULL to start iteration.
[out]nameVariable name.
[out]rettvVariable value.
Returns
Pointer that needs to be passed to next var_shada_iter invocation or NULL to indicate that iteration is over.

◆ vars_clear()

void vars_clear ( hashtab_T ht)

Clean up a list of internal variables. Frees all allocated variables and the value they contain. Clears hashtab "ht", does not free it.

◆ vars_clear_ext()

void vars_clear_ext ( hashtab_T ht,
int  free_val 
)

Like vars_clear(), but only free the value if "free_val" is TRUE.

◆ while()

while ( )

◆ write_blob()

bool write_blob ( FileDescriptor *const  fp,
const blob_T *const  blob 
)

Write a blob to file with descriptor fp.

Parameters
[in]fpFile to write to.
[in]blobBlob to write.
Returns
true on success, or false on failure.

◆ write_list()

bool write_list ( FileDescriptor *const  fp,
const list_T *const  list,
const bool  binary 
)

Write "list" of strings to file "fd".

Parameters
fpFile to write to.
[in]listList to write.
[in]binaryWhether to write in binary mode.
Returns
true in case of success, false otherwise.

◆ xfree()

xfree ( s  )

Variable Documentation

◆ __pad0__

theend __pad0__

◆ added

long added = 0

◆ append_lnum

linenr_T append_lnum

◆ arg

if arg
Initial value:
{
if (is_const) {
emsg(_("E996: Cannot lock an environment variable"));
return NULL;
}
arg++

◆ argv

argv
Initial value:

◆ basetv

funcexe basetv = basetv

◆ called_emsg_before

const int called_emsg_before = called_emsg

◆ curbuf_save

buf_T* curbuf_save = NULL

◆ curwin_save

win_T* curwin_save = NULL

◆ did_emsg_before

int const int did_emsg_before = did_emsg

◆ else

else
Initial value:
{
char buf[NUMBUFLEN]

◆ empty1

int empty1 = FALSE

◆ eval_lavars_used

bool* eval_lavars_used = NULL

Used for checking if local variables or arguments used in a lambda.

◆ eval_msgpack_type_lists

const list_T* eval_msgpack_type_lists[]
Initial value:

Array mapping values from MessagePackType to corresponding list pointers.

◆ evaluate

funcexe evaluate = evaluate

◆ expr_end

char* expr_end

◆ expr_start

char* expr_start

◆ firstline

◆ FUNC_ATTR_WARN_UNUSED_RESULT

char FUNC_ATTR_WARN_UNUSED_RESULT
Initial value:
{
char *arg_end = NULL

◆ funcexe

◆ funcname

const char* funcname

◆ functv

int typval_T functv
Initial value:
{

◆ hifirst

const void const hashitem_T* hifirst = globvarht.ht_array

◆ hinum

const size_t hinum = (size_t)globvarht.ht_mask + 1

◆ ht

hashtab_T* ht = NULL

◆ is_curbuf

const bool is_curbuf = buf == curbuf

◆ is_lua

bool is_lua = false

◆ l

list_T* l = NULL

◆ lastline

◆ len

int int len = get_env_len((const char **)&arg)

◆ li

◆ line

void const char* line = NULL

◆ ll_name_len

lp ll_name_len = (size_t)((const char *)p - lp->ll_name)

◆ ll_tv

lp ll_tv = &v->di_tv

◆ name

* name = arg

◆ ni

◆ NULL

return NULL

◆ OK

return OK

◆ opt_flags

int opt_flags

◆ p

while p
Initial value:
= (char *)find_name_end(name, (const char **)&expr_start,
(const char **)&expr_end,
fne_flags)

◆ partial

funcexe partial = partial

◆ quiet

int quiet = flags & GLV_QUIET

◆ recurse

recurse

◆ remp

* remp = (tv_get_number_chk(&rettv, &error) == 0)

◆ res

return res = (tv_get_number_chk(&rettv, error) != 0)

◆ ret

◆ rettv

tv_clear& rettv

◆ retval

return retval = FAIL

◆ s

s = (char *)tv_get_string_buf_chk(expr, buf)

◆ save_VIsual_active

const bool save_VIsual_active = VIsual_active

◆ selfdict

funcexe selfdict = selfdict

◆ tofree

char* tofree = NULL

◆ v

v
Initial value:
= find_var(lp->ll_name, lp->ll_name_len,
(flags & GLV_READ_ONLY) ? NULL : &ht,
flags & GLV_NO_AUTOLOAD)

◆ v_type

var2 v_type = VAR_UNKNOWN

◆ var1

tv_clear & var1
Initial value:

◆ var2

typval_T var2
kMPInteger
@ kMPInteger
Definition: eval.h:181
ht
hashtab_T * ht
Definition: eval.c:2000
_
#define _(x)
Definition: gettext.h:20
expr_end
char * expr_end
Definition: eval.c:2015
typval_T
Structure that holds an internal variable value.
Definition: typval.h:135
kMPBinary
@ kMPBinary
Definition: eval.h:184
type
err type
Definition: helpers.c:793
kMPFloat
@ kMPFloat
Definition: eval.h:182
find_var
dictitem_T * find_var(const char *const name, const size_t name_len, hashtab_T **htp, int no_autoload)
Definition: eval.c:8612
kMPNil
@ kMPNil
Definition: eval.h:179
kMPString
@ kMPString
Definition: eval.h:183
rettv
tv_clear & rettv
Definition: eval.c:827
kMPMap
@ kMPMap
Definition: eval.h:186
buf
char *const buf
Definition: encode.c:234
NUMBUFLEN
@ NUMBUFLEN
Definition: vim.h:26
partial_S
Definition: typval.h:364
kMPArray
@ kMPArray
Definition: eval.h:185
kMPBoolean
@ kMPBoolean
Definition: eval.h:180
find_name_end
const char * find_name_end(const char *arg, const char **expr_start, const char **expr_end, int flags)
Definition: eval.c:7993
v
v
Definition: eval.c:2054
dictitem_T
Definition: coverity-model.c:39
GLV_READ_ONLY
@ GLV_READ_ONLY
Definition: eval.h:215
arg
if arg
Definition: eval.c:1799
name
char * name
Definition: eval.c:1806
GLV_NO_AUTOLOAD
@ GLV_NO_AUTOLOAD
Do not use script autoloading.
Definition: eval.h:214
expr_start
char * expr_start
Definition: eval.c:2014
emsg
bool emsg(const char *s)
Definition: message.c:751
NULL
return NULL
Definition: eval.c:9914
kMPExt
@ kMPExt
Definition: eval.h:187