vim-patch:8.1.1210: support for user commands is spread out (#19653)

Problem:    Support for user commands is spread out. No good reason to make
            user commands optional.
Solution:   Move user command support to usercmd.c.  Always enable the
            user_commands feature.
ac9fb18020
This commit is contained in:
zeertzjq 2022-08-06 17:14:37 +08:00 committed by GitHub
parent 5f0fbe7c2f
commit ad7064bd83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1781 additions and 1739 deletions

View File

@ -14,6 +14,7 @@
#include "nvim/lua/executor.h" #include "nvim/lua/executor.h"
#include "nvim/ops.h" #include "nvim/ops.h"
#include "nvim/regexp.h" #include "nvim/regexp.h"
#include "nvim/usercmd.h"
#include "nvim/window.h" #include "nvim/window.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -76,6 +76,7 @@
#include "nvim/syntax.h" #include "nvim/syntax.h"
#include "nvim/ui.h" #include "nvim/ui.h"
#include "nvim/undo.h" #include "nvim/undo.h"
#include "nvim/usercmd.h"
#include "nvim/version.h" #include "nvim/version.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/window.h" #include "nvim/window.h"

File diff suppressed because it is too large Load Diff

View File

@ -33,27 +33,6 @@ typedef struct {
tasave_T tabuf; tasave_T tabuf;
} save_state_T; } save_state_T;
typedef struct ucmd {
char_u *uc_name; // The command name
uint32_t uc_argt; // The argument type
char_u *uc_rep; // The command's replacement string
long uc_def; // The default value for a range/count
int uc_compl; // completion type
cmd_addr_T uc_addr_type; // The command's address type
sctx_T uc_script_ctx; // SCTX where the command was defined
char_u *uc_compl_arg; // completion argument if any
LuaRef uc_compl_luaref; // Reference to Lua completion function
LuaRef uc_preview_luaref; // Reference to Lua preview function
LuaRef uc_luaref; // Reference to Lua function
} ucmd_T;
#define UC_BUFFER 1 // -buffer: local to current buffer
extern garray_T ucmds;
#define USER_CMD(i) (&((ucmd_T *)(ucmds.ga_data))[i])
#define USER_CMD_GA(gap, i) (&((ucmd_T *)((gap)->ga_data))[i])
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ex_docmd.h.generated.h" # include "ex_docmd.h.generated.h"
#endif #endif

View File

@ -17,6 +17,7 @@
#include "nvim/cursor.h" #include "nvim/cursor.h"
#include "nvim/edit.h" #include "nvim/edit.h"
#include "nvim/event/loop.h" #include "nvim/event/loop.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h" #include "nvim/ex_getln.h"
#include "nvim/garray.h" #include "nvim/garray.h"
#include "nvim/getchar.h" #include "nvim/getchar.h"

View File

@ -21,7 +21,6 @@
#include "nvim/event/loop.h" #include "nvim/event/loop.h"
#include "nvim/event/time.h" #include "nvim/event/time.h"
#include "nvim/ex_cmds2.h" #include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h" #include "nvim/ex_getln.h"
#include "nvim/extmark.h" #include "nvim/extmark.h"
#include "nvim/func_attr.h" #include "nvim/func_attr.h"
@ -40,6 +39,7 @@
#include "nvim/profile.h" #include "nvim/profile.h"
#include "nvim/screen.h" #include "nvim/screen.h"
#include "nvim/undo.h" #include "nvim/undo.h"
#include "nvim/usercmd.h"
#include "nvim/version.h" #include "nvim/version.h"
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/window.h" #include "nvim/window.h"

View File

@ -8,9 +8,9 @@
#include "nvim/assert.h" #include "nvim/assert.h"
#include "nvim/eval/typval.h" #include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h" #include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/func_attr.h" #include "nvim/func_attr.h"
#include "nvim/lua/converter.h" #include "nvim/lua/converter.h"
#include "nvim/usercmd.h"
// Generated by msgpack-gen.lua // Generated by msgpack-gen.lua
void nlua_add_api_functions(lua_State *lstate) REAL_FATTR_NONNULL_ALL; void nlua_add_api_functions(lua_State *lstate) REAL_FATTR_NONNULL_ALL;

1740
src/nvim/usercmd.c Normal file

File diff suppressed because it is too large Load Diff

30
src/nvim/usercmd.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef NVIM_USERCMD_H
#define NVIM_USERCMD_H
#include "nvim/ex_cmds_defs.h"
typedef struct ucmd {
char_u *uc_name; // The command name
uint32_t uc_argt; // The argument type
char_u *uc_rep; // The command's replacement string
long uc_def; // The default value for a range/count
int uc_compl; // completion type
cmd_addr_T uc_addr_type; // The command's address type
sctx_T uc_script_ctx; // SCTX where the command was defined
char_u *uc_compl_arg; // completion argument if any
LuaRef uc_compl_luaref; // Reference to Lua completion function
LuaRef uc_preview_luaref; // Reference to Lua preview function
LuaRef uc_luaref; // Reference to Lua function
} ucmd_T;
#define UC_BUFFER 1 // -buffer: local to current buffer
extern garray_T ucmds;
#define USER_CMD(i) (&((ucmd_T *)(ucmds.ga_data))[i])
#define USER_CMD_GA(gap, i) (&((ucmd_T *)((gap)->ga_data))[i])
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "usercmd.h.generated.h"
#endif
#endif // NVIM_USERCMD_H