diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-02 10:45:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 10:45:33 +0800 |
commit | 09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9 (patch) | |
tree | 204374657c5c6a7815d4aa612563c32feec18b28 /src | |
parent | 9ce1623837a817c3f4f5deff9c8ba862578b6009 (diff) | |
download | rneovim-09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9.tar.gz rneovim-09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9.tar.bz2 rneovim-09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9.zip |
refactor: move cmdline completion types to cmdexpand_defs.h (#25465)
Diffstat (limited to 'src')
60 files changed, 245 insertions, 189 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index eb32f46143..f4c6f646eb 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -17,6 +17,7 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/decoration.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index a4221a1562..fb8849541d 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -14,6 +14,7 @@ #include "nvim/autocmd.h" #include "nvim/buffer.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/window.h" diff --git a/src/nvim/arglist.h b/src/nvim/arglist.h index 52894b73a0..bd5cfb4a11 100644 --- a/src/nvim/arglist.h +++ b/src/nvim/arglist.h @@ -2,6 +2,7 @@ #define NVIM_ARGLIST_H #include "nvim/arglist_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/types.h" diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h index b3de57311e..324a31be47 100644 --- a/src/nvim/autocmd.h +++ b/src/nvim/autocmd.h @@ -6,6 +6,7 @@ #include "nvim/api/private/defs.h" #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/macros.h" diff --git a/src/nvim/cmdexpand.h b/src/nvim/cmdexpand.h index f37c693a22..81e323c97b 100644 --- a/src/nvim/cmdexpand.h +++ b/src/nvim/cmdexpand.h @@ -1,6 +1,7 @@ #ifndef NVIM_CMDEXPAND_H #define NVIM_CMDEXPAND_H +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_getln.h" #include "nvim/garray.h" @@ -41,9 +42,6 @@ enum { BUF_DIFF_FILTER = 0x2000, }; -/// Type used by ExpandGeneric() -typedef char *(*CompleteListItemGetter)(expand_T *, int); - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "cmdexpand.h.generated.h" #endif diff --git a/src/nvim/cmdexpand_defs.h b/src/nvim/cmdexpand_defs.h new file mode 100644 index 0000000000..a302a32852 --- /dev/null +++ b/src/nvim/cmdexpand_defs.h @@ -0,0 +1,113 @@ +#ifndef NVIM_CMDEXPAND_DEFS_H +#define NVIM_CMDEXPAND_DEFS_H + +#include <stdbool.h> +#include <stddef.h> + +#include "nvim/eval/typval_defs.h" +#include "nvim/types.h" + +typedef enum { + XP_PREFIX_NONE, ///< prefix not used + XP_PREFIX_NO, ///< "no" prefix for bool option + XP_PREFIX_INV, ///< "inv" prefix for bool option +} xp_prefix_T; + +enum { EXPAND_BUF_LEN = 256, }; + +/// used for completion on the command line +typedef struct expand { + char *xp_pattern; ///< start of item to expand + int xp_context; ///< type of expansion + size_t xp_pattern_len; ///< bytes in xp_pattern before cursor + xp_prefix_T xp_prefix; + char *xp_arg; ///< completion function + LuaRef xp_luaref; ///< Ref to Lua completion function + sctx_T xp_script_ctx; ///< SCTX for completion function + int xp_backslash; ///< one of the XP_BS_ values +#ifndef BACKSLASH_IN_FILENAME + bool xp_shell; ///< true for a shell command, more + ///< characters need to be escaped +#endif + int xp_numfiles; ///< number of files found by file name completion + int xp_col; ///< cursor position in line + int xp_selected; ///< selected index in completion + char *xp_orig; ///< originally expanded string + char **xp_files; ///< list of files + char *xp_line; ///< text being completed + char xp_buf[EXPAND_BUF_LEN]; ///< buffer for returned match +} expand_T; + +/// values for xp_backslash +enum { + XP_BS_NONE = 0, ///< nothing special for backslashes + XP_BS_ONE = 1, ///< uses one backslash before a space + XP_BS_THREE = 2, ///< uses three backslashes before a space +}; + +/// values for xp_context when doing command line completion +enum { + EXPAND_UNSUCCESSFUL = -2, + EXPAND_OK = -1, + EXPAND_NOTHING = 0, + EXPAND_COMMANDS, + EXPAND_FILES, + EXPAND_DIRECTORIES, + EXPAND_SETTINGS, + EXPAND_BOOL_SETTINGS, + EXPAND_TAGS, + EXPAND_OLD_SETTING, + EXPAND_HELP, + EXPAND_BUFFERS, + EXPAND_EVENTS, + EXPAND_MENUS, + EXPAND_SYNTAX, + EXPAND_HIGHLIGHT, + EXPAND_AUGROUP, + EXPAND_USER_VARS, + EXPAND_MAPPINGS, + EXPAND_TAGS_LISTFILES, + EXPAND_FUNCTIONS, + EXPAND_USER_FUNC, + EXPAND_EXPRESSION, + EXPAND_MENUNAMES, + EXPAND_USER_COMMANDS, + EXPAND_USER_CMD_FLAGS, + EXPAND_USER_NARGS, + EXPAND_USER_COMPLETE, + EXPAND_ENV_VARS, + EXPAND_LANGUAGE, + EXPAND_COLORS, + EXPAND_COMPILER, + EXPAND_USER_DEFINED, + EXPAND_USER_LIST, + EXPAND_USER_LUA, + EXPAND_SHELLCMD, + EXPAND_SIGN, + EXPAND_PROFILE, + EXPAND_FILETYPE, + EXPAND_FILES_IN_PATH, + EXPAND_OWNSYNTAX, + EXPAND_LOCALES, + EXPAND_HISTORY, + EXPAND_USER, + EXPAND_SYNTIME, + EXPAND_USER_ADDR_TYPE, + EXPAND_PACKADD, + EXPAND_MESSAGES, + EXPAND_MAPCLEAR, + EXPAND_ARGLIST, + EXPAND_DIFF_BUFFERS, + EXPAND_BREAKPOINT, + EXPAND_SCRIPTNAMES, + EXPAND_RUNTIME, + EXPAND_STRING_SETTING, + EXPAND_SETTING_SUBTRACT, + EXPAND_CHECKHEALTH, + EXPAND_LUA, +}; + +/// Type used by ExpandGeneric() +typedef char *(*CompleteListItemGetter)(expand_T *, int); + +#endif // NVIM_CMDEXPAND_DEFS_H diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 50bdfd892f..b0490670fe 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -12,6 +12,7 @@ #include "nvim/ascii.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cmdhist.h" #include "nvim/eval/typval.h" #include "nvim/ex_cmds.h" diff --git a/src/nvim/cmdhist.h b/src/nvim/cmdhist.h index a0f2ab6934..2b7e47e38e 100644 --- a/src/nvim/cmdhist.h +++ b/src/nvim/cmdhist.h @@ -1,6 +1,7 @@ #ifndef NVIM_CMDHIST_H #define NVIM_CMDHIST_H +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/os/time.h" diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 3d5f27e76c..755579a3bc 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -12,6 +12,7 @@ #include "nvim/ascii.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0bf26b2451..014335f5ed 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21,6 +21,7 @@ #include "nvim/buffer_defs.h" #include "nvim/channel.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cmdhist.h" #include "nvim/cursor.h" #include "nvim/edit.h" diff --git a/src/nvim/eval.h b/src/nvim/eval.h index be69cd5657..38bcf8f50d 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -6,6 +6,7 @@ #include "nvim/buffer_defs.h" #include "nvim/channel.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/event/time.h" #include "nvim/ex_cmds_defs.h" diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 5bfce7c272..ee70731c7c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -33,6 +33,7 @@ #include "nvim/channel.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/context.h" #include "nvim/cursor.h" #include "nvim/diff.h" diff --git a/src/nvim/eval/funcs.h b/src/nvim/eval/funcs.h index 5dab12787b..5f6132f68c 100644 --- a/src/nvim/eval/funcs.h +++ b/src/nvim/eval/funcs.h @@ -6,6 +6,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/types.h" diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h index d5e8cb0109..c0b5416a05 100644 --- a/src/nvim/eval/typval_defs.h +++ b/src/nvim/eval/typval_defs.h @@ -115,6 +115,19 @@ typedef enum { VAR_BLOB, ///< Blob, .v_blob is used. } VarType; +/// Type values for type(). +enum { + VAR_TYPE_NUMBER = 0, + VAR_TYPE_STRING = 1, + VAR_TYPE_FUNC = 2, + VAR_TYPE_LIST = 3, + VAR_TYPE_DICT = 4, + VAR_TYPE_FLOAT = 5, + VAR_TYPE_BOOL = 6, + VAR_TYPE_SPECIAL = 7, + VAR_TYPE_BLOB = 10, +}; + /// Structure that holds an internal variable value typedef struct { VarType v_type; ///< Variable type. diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8d85c55e15..6b9801b805 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -14,6 +14,7 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/encode.h" diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h index 562c549b4b..c3fe56d30c 100644 --- a/src/nvim/eval/userfunc.h +++ b/src/nvim/eval/userfunc.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include <stddef.h> +#include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 127397d9fa..eb1ce5457e 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -27,6 +27,7 @@ #include "nvim/change.h" #include "nvim/channel.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cmdhist.h" #include "nvim/cursor.h" #include "nvim/decoration.h" diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 78f880db56..111e9539c4 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -5,6 +5,7 @@ #include <stdint.h> #include "nvim/eval/typval_defs.h" +#include "nvim/ex_eval_defs.h" #include "nvim/normal.h" #include "nvim/pos.h" #include "nvim/regexp_defs.h" @@ -69,20 +70,20 @@ #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file #define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed -// values for cmd_addr_type +/// values for cmd_addr_type typedef enum { - ADDR_LINES, // buffer line numbers - ADDR_WINDOWS, // window number - ADDR_ARGUMENTS, // argument number - ADDR_LOADED_BUFFERS, // buffer number of loaded buffer - ADDR_BUFFERS, // buffer number - ADDR_TABS, // tab page number - ADDR_TABS_RELATIVE, // Tab page that only relative - ADDR_QUICKFIX_VALID, // quickfix list valid entry number - ADDR_QUICKFIX, // quickfix list entry number - ADDR_UNSIGNED, // positive count or zero, defaults to 1 - ADDR_OTHER, // something else, use line number for '$', '%', etc. - ADDR_NONE, // no range used + ADDR_LINES, ///< buffer line numbers + ADDR_WINDOWS, ///< window number + ADDR_ARGUMENTS, ///< argument number + ADDR_LOADED_BUFFERS, ///< buffer number of loaded buffer + ADDR_BUFFERS, ///< buffer number + ADDR_TABS, ///< tab page number + ADDR_TABS_RELATIVE, ///< Tab page that only relative + ADDR_QUICKFIX_VALID, ///< quickfix list valid entry number + ADDR_QUICKFIX, ///< quickfix list entry number + ADDR_UNSIGNED, ///< positive count or zero, defaults to 1 + ADDR_OTHER, ///< something else, use line number for '$', '%', etc. + ADDR_NONE, ///< no range used } cmd_addr_T; typedef struct exarg exarg_T; @@ -128,54 +129,13 @@ typedef char *(*LineGetter)(int, void *, int, bool); /// Structure for command definition. typedef struct cmdname { - char *cmd_name; ///< Name of the command. - ex_func_T cmd_func; ///< Function with implementation of this command. - ex_preview_func_T cmd_preview_func; ///< Preview callback function of this command. - uint32_t cmd_argt; ///< Relevant flags from the declared above. - cmd_addr_T cmd_addr_type; ///< Flag for address type. + char *cmd_name; ///< Name of the command. + ex_func_T cmd_func; ///< Function with implementation of this command. + ex_preview_func_T cmd_preview_func; ///< Preview callback function of this command. + uint32_t cmd_argt; ///< Relevant flags from the declared above. + cmd_addr_T cmd_addr_type; ///< Flag for address type. } CommandDefinition; -// A list used for saving values of "emsg_silent". Used by ex_try() to save the -// value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT -// flag below is set. -typedef struct eslist_elem eslist_T; -struct eslist_elem { - int saved_emsg_silent; // saved value of "emsg_silent" - eslist_T *next; // next element on the list -}; - -// For conditional commands a stack is kept of nested conditionals. -// When cs_idx < 0, there is no conditional command. -enum { - CSTACK_LEN = 50, -}; - -typedef struct { - int cs_flags[CSTACK_LEN]; // CSF_ flags - char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally" - union { - void *csp_rv[CSTACK_LEN]; // return typeval for pending return - void *csp_ex[CSTACK_LEN]; // exception for pending throw - } cs_pend; - void *cs_forinfo[CSTACK_LEN]; // info used by ":for" - int cs_line[CSTACK_LEN]; // line nr of ":while"/":for" line - int cs_idx; // current entry, or -1 if none - int cs_looplevel; // nr of nested ":while"s and ":for"s - int cs_trylevel; // nr of nested ":try"s - eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent" - int cs_lflags; // loop flags: CSL_ flags -} cstack_T; -#define cs_rettv cs_pend.csp_rv -#define cs_exception cs_pend.csp_ex - -// Flags for the cs_lflags item in cstack_T. -enum { - CSL_HAD_LOOP = 1, // just found ":while" or ":for" - CSL_HAD_ENDLOOP = 2, // just found ":endwhile" or ":endfor" - CSL_HAD_CONT = 4, // just found ":continue" - CSL_HAD_FINA = 8, // just found ":finally" -}; - /// Arguments used for Ex commands. struct exarg { char *arg; ///< argument of the command @@ -222,41 +182,6 @@ struct exarg { #define EXFLAG_NR 0x02 // '#': number #define EXFLAG_PRINT 0x04 // 'p': print -typedef enum { - XP_PREFIX_NONE, ///< prefix not used - XP_PREFIX_NO, ///< "no" prefix for bool option - XP_PREFIX_INV, ///< "inv" prefix for bool option -} xp_prefix_T; - -// used for completion on the command line -struct expand { - char *xp_pattern; // start of item to expand - int xp_context; // type of expansion - size_t xp_pattern_len; // bytes in xp_pattern before cursor - xp_prefix_T xp_prefix; - char *xp_arg; // completion function - LuaRef xp_luaref; // Ref to Lua completion function - sctx_T xp_script_ctx; // SCTX for completion function - int xp_backslash; // one of the XP_BS_ values -#ifndef BACKSLASH_IN_FILENAME - int xp_shell; // true for a shell command, more - // characters need to be escaped -#endif - int xp_numfiles; // number of files found by file name completion - int xp_col; // cursor position in line - int xp_selected; // selected index in completion - char *xp_orig; // originally expanded string - char **xp_files; // list of files - char *xp_line; // text being completed -#define EXPAND_BUF_LEN 256 - char xp_buf[EXPAND_BUF_LEN]; // buffer for returned match -}; - -// values for xp_backslash -#define XP_BS_NONE 0 // nothing special for backslashes -#define XP_BS_ONE 1 // uses one backslash before a space -#define XP_BS_THREE 2 // uses three backslashes before a space - enum { CMOD_SANDBOX = 0x0001, ///< ":sandbox" CMOD_SILENT = 0x0002, ///< ":silent" diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 02783e032b..ff036dbd42 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -22,6 +22,7 @@ #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/debugger.h" #include "nvim/digraph.h" diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h index 0fd14c81d3..59f45fce88 100644 --- a/src/nvim/ex_docmd.h +++ b/src/nvim/ex_docmd.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/getchar_defs.h" #include "nvim/globals.h" diff --git a/src/nvim/ex_eval_defs.h b/src/nvim/ex_eval_defs.h index 3ad3368900..6713cdb549 100644 --- a/src/nvim/ex_eval_defs.h +++ b/src/nvim/ex_eval_defs.h @@ -5,6 +5,37 @@ #include "nvim/pos.h" +/// A list used for saving values of "emsg_silent". Used by ex_try() to save the +/// value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT +/// flag below is set. +typedef struct eslist_elem eslist_T; +struct eslist_elem { + int saved_emsg_silent; ///< saved value of "emsg_silent" + eslist_T *next; ///< next element on the list +}; + +/// For conditional commands a stack is kept of nested conditionals. +/// When cs_idx < 0, there is no conditional command. +enum { CSTACK_LEN = 50, }; + +typedef struct { + int cs_flags[CSTACK_LEN]; ///< CSF_ flags + char cs_pending[CSTACK_LEN]; ///< CSTP_: what's pending in ":finally" + union { + void *csp_rv[CSTACK_LEN]; ///< return typeval for pending return + void *csp_ex[CSTACK_LEN]; ///< exception for pending throw + } cs_pend; + void *cs_forinfo[CSTACK_LEN]; ///< info used by ":for" + int cs_line[CSTACK_LEN]; ///< line nr of ":while"/":for" line + int cs_idx; ///< current entry, or -1 if none + int cs_looplevel; ///< nr of nested ":while"s and ":for"s + int cs_trylevel; ///< nr of nested ":try"s + eslist_T *cs_emsg_silent_list; ///< saved values of "emsg_silent" + int cs_lflags; ///< loop flags: CSL_ flags +} cstack_T; +#define cs_rettv cs_pend.csp_rv +#define cs_exception cs_pend.csp_ex + /// There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if" /// was used. enum { @@ -37,6 +68,14 @@ enum { CSTP_FINISH = 32, ///< ":finish" is pending }; +/// Flags for the cs_lflags item in cstack_T. +enum { + CSL_HAD_LOOP = 1, ///< just found ":while" or ":for" + CSL_HAD_ENDLOOP = 2, ///< just found ":endwhile" or ":endfor" + CSL_HAD_CONT = 4, ///< just found ":continue" + CSL_HAD_FINA = 8, ///< just found ":finally" +}; + /// A list of error messages that can be converted to an exception. "throw_msg" /// is only set in the first element of the list. Usually, it points to the /// original message stored in that element, but sometimes it points to a later diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2d1633f312..4ec5e890b9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -71,6 +71,7 @@ #include "nvim/search.h" #include "nvim/state.h" #include "nvim/strings.h" +#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/usercmd.h" diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index aaafedcb4b..61bbd5b9e1 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include "klib/kvec.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/option_defs.h" diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 4e8b7be4aa..e94dfceaad 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -28,7 +28,7 @@ #include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/eval.h" -#include "nvim/ex_cmds.h" +#include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval.h" #include "nvim/fileio.h" #include "nvim/fold.h" diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 5eb2689233..92ea866239 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -3,7 +3,10 @@ #include "nvim/buffer_defs.h" #include "nvim/eval/typval_defs.h" +#include "nvim/ex_cmds_defs.h" #include "nvim/garray.h" +#include "nvim/globals.h" +#include "nvim/os/fs_defs.h" #include "nvim/os/os.h" // Values for readfile() flags diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index d2cdcb2516..c526df5de4 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -18,13 +18,13 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor_shape.h" #include "nvim/decoration_provider.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" #include "nvim/eval/vars.h" -#include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" #include "nvim/gettext.h" diff --git a/src/nvim/highlight_group.h b/src/nvim/highlight_group.h index 77a3684067..369864552c 100644 --- a/src/nvim/highlight_group.h +++ b/src/nvim/highlight_group.h @@ -3,6 +3,7 @@ #include "nvim/api/keysets.h" #include "nvim/api/private/helpers.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/highlight_defs.h" #include "nvim/types.h" diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 4a6c819015..3ada39c800 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -24,7 +24,6 @@ #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/userfunc.h" -#include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 18da7af416..d6fd14cc10 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -20,6 +20,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/change.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h index b132a0d147..f3e2b6d1d0 100644 --- a/src/nvim/lua/executor.h +++ b/src/nvim/lua/executor.h @@ -8,6 +8,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/assert.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 1fb91d85b4..2cfa264754 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -21,6 +21,7 @@ #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" diff --git a/src/nvim/mapping.h b/src/nvim/mapping.h index 405234dbd5..860bbad272 100644 --- a/src/nvim/mapping.h +++ b/src/nvim/mapping.h @@ -7,6 +7,7 @@ #include "nvim/api/keysets.h" #include "nvim/api/private/defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/mapping_defs.h" diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 124855fd08..4191b4dcc5 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -43,6 +43,7 @@ #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/eval/typval.h" diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index 724a16014d..01a7d0d6ae 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -5,6 +5,7 @@ #include <stdint.h> #include <string.h> +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/func_attr.h" #include "nvim/mbyte_defs.h" diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 2204a0a291..9a403c4192 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -12,6 +12,7 @@ #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" diff --git a/src/nvim/menu.h b/src/nvim/menu.h index 32959cf35f..8d7a98d270 100644 --- a/src/nvim/menu.h +++ b/src/nvim/menu.h @@ -3,6 +3,7 @@ #include <stdbool.h> +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/menu_defs.h" #include "nvim/types.h" diff --git a/src/nvim/option.c b/src/nvim/option.c index 932b900414..e709a810bc 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -40,6 +40,7 @@ #include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor_shape.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" diff --git a/src/nvim/option.h b/src/nvim/option.h index 8417d152e7..593917407a 100644 --- a/src/nvim/option.h +++ b/src/nvim/option.h @@ -4,6 +4,7 @@ #include <stdint.h> #include "nvim/api/private/helpers.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/option_defs.h" diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index dd637aacf5..a11ed9188c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -1,8 +1,11 @@ #ifndef NVIM_OPTION_DEFS_H #define NVIM_OPTION_DEFS_H +#include <stdbool.h> +#include <stddef.h> + #include "nvim/api/private/defs.h" -#include "nvim/eval/typval_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/regexp_defs.h" #include "nvim/types.h" diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index c8a589f96a..6f41bba99b 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -12,6 +12,7 @@ #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/cursor_shape.h" #include "nvim/diff.h" diff --git a/src/nvim/optionstr.h b/src/nvim/optionstr.h index 0993b67c9a..a481ed1d07 100644 --- a/src/nvim/optionstr.h +++ b/src/nvim/optionstr.h @@ -2,7 +2,7 @@ #define NVIM_OPTIONSTR_H #include "nvim/buffer_defs.h" -#include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/option_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index b03509a313..7de7168d62 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -17,7 +17,6 @@ #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/eval.h" -#include "nvim/ex_cmds_defs.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/log.h" @@ -29,7 +28,6 @@ #include "nvim/os/os.h" #include "nvim/path.h" #include "nvim/strings.h" -#include "nvim/types.h" #include "nvim/version.h" #include "nvim/vim.h" diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index 652b851903..c3958cb3f2 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -5,6 +5,7 @@ # define Boolean CFBoolean // Avoid conflict with API's Boolean # define FileInfo CSFileInfo // Avoid conflict with API's Fileinfo # include <CoreServices/CoreServices.h> + # undef Boolean # undef FileInfo #endif @@ -17,6 +18,7 @@ #include "nvim/ascii.h" #include "nvim/buffer.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" #include "nvim/ex_cmds_defs.h" #include "nvim/garray.h" @@ -30,7 +32,6 @@ #include "nvim/os/shell.h" #include "nvim/path.h" #include "nvim/profile.h" -#include "nvim/types.h" #include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/os/lang.h b/src/nvim/os/lang.h index bb1ebfb721..ad64b38916 100644 --- a/src/nvim/os/lang.h +++ b/src/nvim/os/lang.h @@ -1,6 +1,7 @@ #ifndef NVIM_OS_LANG_H #define NVIM_OS_LANG_H +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/types.h" diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index a7496130cc..006dfbfc04 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -4,9 +4,12 @@ #include <stdbool.h> #include <uv.h> +#include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" +#include "nvim/garray.h" #include "nvim/os/fs_defs.h" #include "nvim/os/stdpaths_defs.h" -#include "nvim/vim.h" +#include "nvim/types.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/env.h.generated.h" diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 411ba91fa7..b23d2b7b13 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -10,10 +10,10 @@ #include "auto/config.h" #include "nvim/ascii.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/garray.h" #include "nvim/memory.h" #include "nvim/os/os.h" -#include "nvim/types.h" #include "nvim/vim.h" #ifdef HAVE_PWD_FUNCS # include <pwd.h> diff --git a/src/nvim/profile.c b/src/nvim/profile.c index 3162a446c0..73ad534de7 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -11,6 +11,7 @@ #include "nvim/ascii.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" @@ -30,7 +31,6 @@ #include "nvim/profile.h" #include "nvim/runtime.h" #include "nvim/types.h" -#include "nvim/vim.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "profile.c.generated.h" diff --git a/src/nvim/profile.h b/src/nvim/profile.h index 547d11185f..7450a0dfdc 100644 --- a/src/nvim/profile.h +++ b/src/nvim/profile.h @@ -4,6 +4,7 @@ #include <stdint.h> #include <time.h> +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/runtime.h" diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 12cf08636f..360088758d 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -20,6 +20,7 @@ #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/debugger.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h index 7308ef5f75..8286a11f89 100644 --- a/src/nvim/runtime.h +++ b/src/nvim/runtime.h @@ -5,6 +5,7 @@ #include "klib/kvec.h" #include "nvim/autocmd.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_eval_defs.h" diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 14d35d9b59..cd1d016c7b 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1564,15 +1564,14 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr break; } case kSDItemVariable: { - if (entry.data.global_var.value.v_type == VAR_TYPE_BLOB) { + if (entry.data.global_var.value.v_type == VAR_BLOB) { // Strings and Blobs both pack as msgpack BINs; differentiate them by // storing an additional VAR_TYPE_BLOB element alongside Blobs list_T *const list = tv_list_alloc(1); tv_list_append_number(list, VAR_TYPE_BLOB); entry.data.global_var.additional_elements = list; } - const size_t arr_size = 2 + (size_t)( - tv_list_len(entry.data.global_var.additional_elements)); + const size_t arr_size = 2 + (size_t)(tv_list_len(entry.data.global_var.additional_elements)); msgpack_pack_array(spacker, arr_size); const String varname = cstr_as_string(entry.data.global_var.name); PACK_BIN(varname); diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 96af14bfc6..5d18ed393a 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -16,6 +16,7 @@ #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" diff --git a/src/nvim/sign.h b/src/nvim/sign.h index ba84cd71a4..89d765bf38 100644 --- a/src/nvim/sign.h +++ b/src/nvim/sign.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/sign_defs.h" diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 9b238e6ff9..18f0b796d1 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -15,6 +15,7 @@ #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/drawscreen.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h index 0a63392a04..c56624bc37 100644 --- a/src/nvim/syntax.h +++ b/src/nvim/syntax.h @@ -4,6 +4,7 @@ #include <stdbool.h> #include "nvim/buffer_defs.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/globals.h" #include "nvim/macros.h" diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 636d16d4e6..674d22ba44 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -56,7 +56,6 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/tag.h" -#include "nvim/types.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.h" diff --git a/src/nvim/types.h b/src/nvim/types.h index c2c815a0bc..7b23fe419b 100644 --- a/src/nvim/types.h +++ b/src/nvim/types.h @@ -31,8 +31,6 @@ typedef union { typedef handle_T NS; -typedef struct expand expand_T; - typedef uint64_t proftime_T; typedef enum { diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index 131b1ce3ef..4bab3f52cd 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -16,6 +16,7 @@ #include "nvim/ascii.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" +#include "nvim/cmdexpand_defs.h" #include "nvim/eval.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" diff --git a/src/nvim/usercmd.h b/src/nvim/usercmd.h index 0d9838abf2..34f1439b10 100644 --- a/src/nvim/usercmd.h +++ b/src/nvim/usercmd.h @@ -3,6 +3,7 @@ #include <stdint.h> +#include "nvim/cmdexpand_defs.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/garray.h" diff --git a/src/nvim/vim.h b/src/nvim/vim.h index da88202525..22db3751cd 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -96,85 +96,10 @@ typedef enum { #define FAIL 0 #define NOTDONE 2 // not OK or FAIL but skipped -// Type values for type(). -#define VAR_TYPE_NUMBER 0 -#define VAR_TYPE_STRING 1 -#define VAR_TYPE_FUNC 2 -#define VAR_TYPE_LIST 3 -#define VAR_TYPE_DICT 4 -#define VAR_TYPE_FLOAT 5 -#define VAR_TYPE_BOOL 6 -#define VAR_TYPE_SPECIAL 7 -#define VAR_TYPE_BLOB 10 - -// values for xp_context when doing command line completion - -enum { - EXPAND_UNSUCCESSFUL = -2, - EXPAND_OK = -1, - EXPAND_NOTHING = 0, - EXPAND_COMMANDS, - EXPAND_FILES, - EXPAND_DIRECTORIES, - EXPAND_SETTINGS, - EXPAND_BOOL_SETTINGS, - EXPAND_TAGS, - EXPAND_OLD_SETTING, - EXPAND_HELP, - EXPAND_BUFFERS, - EXPAND_EVENTS, - EXPAND_MENUS, - EXPAND_SYNTAX, - EXPAND_HIGHLIGHT, - EXPAND_AUGROUP, - EXPAND_USER_VARS, - EXPAND_MAPPINGS, - EXPAND_TAGS_LISTFILES, - EXPAND_FUNCTIONS, - EXPAND_USER_FUNC, - EXPAND_EXPRESSION, - EXPAND_MENUNAMES, - EXPAND_USER_COMMANDS, - EXPAND_USER_CMD_FLAGS, - EXPAND_USER_NARGS, - EXPAND_USER_COMPLETE, - EXPAND_ENV_VARS, - EXPAND_LANGUAGE, - EXPAND_COLORS, - EXPAND_COMPILER, - EXPAND_USER_DEFINED, - EXPAND_USER_LIST, - EXPAND_USER_LUA, - EXPAND_SHELLCMD, - EXPAND_SIGN, - EXPAND_PROFILE, - EXPAND_FILETYPE, - EXPAND_FILES_IN_PATH, - EXPAND_OWNSYNTAX, - EXPAND_LOCALES, - EXPAND_HISTORY, - EXPAND_USER, - EXPAND_SYNTIME, - EXPAND_USER_ADDR_TYPE, - EXPAND_PACKADD, - EXPAND_MESSAGES, - EXPAND_MAPCLEAR, - EXPAND_ARGLIST, - EXPAND_DIFF_BUFFERS, - EXPAND_BREAKPOINT, - EXPAND_SCRIPTNAMES, - EXPAND_RUNTIME, - EXPAND_STRING_SETTING, - EXPAND_SETTING_SUBTRACT, - EXPAND_CHECKHEALTH, - EXPAND_LUA, -}; - // Minimal size for block 0 of a swap file. // NOTE: This depends on size of struct block0! It's not done with a sizeof(), // because struct block0 is defined in memline.c (Sorry). // The maximal block size is arbitrary. - #define MIN_SWAP_PAGE_SIZE 1048 #define MAX_SWAP_PAGE_SIZE 50000 |