mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
refactor: move autocmd types to autocmd_defs.h (#26239)
This commit is contained in:
parent
09541d514d
commit
6343d41436
1
Makefile
1
Makefile
@ -160,6 +160,7 @@ iwyu: build/.ran-cmake
|
|||||||
|src/nvim/ascii.h\
|
|src/nvim/ascii.h\
|
||||||
|src/nvim/assert.h\
|
|src/nvim/assert.h\
|
||||||
|src/nvim/autocmd.h\
|
|src/nvim/autocmd.h\
|
||||||
|
|src/nvim/autocmd_defs.h\
|
||||||
|src/nvim/base64.h\
|
|src/nvim/base64.h\
|
||||||
|src/nvim/buffer.h\
|
|src/nvim/buffer.h\
|
||||||
|src/nvim/buffer_defs.h\
|
|src/nvim/buffer_defs.h\
|
||||||
|
@ -171,8 +171,6 @@
|
|||||||
|
|
||||||
# Generated to normal headers with a different name: header.h.generated.h -> nvim/some_other_header.h
|
# Generated to normal headers with a different name: header.h.generated.h -> nvim/some_other_header.h
|
||||||
{ include: [ '"api/private/dispatch_wrappers.h.generated.h"', private, '"nvim/api/private/dispatch.h"', public ] },
|
{ include: [ '"api/private/dispatch_wrappers.h.generated.h"', private, '"nvim/api/private/dispatch.h"', public ] },
|
||||||
{ include: [ '"auevents_enum.generated.h"', private, '"nvim/autocmd.h"', public ] },
|
|
||||||
{ include: [ '"ex_cmds_enum.generated.h"', private, '"nvim/ex_cmds_defs.h"', public ] },
|
|
||||||
{ include: [ '"keysets.h.generated.h"', private, '"nvim/api/private/helpers.h"', public ] },
|
{ include: [ '"keysets.h.generated.h"', private, '"nvim/api/private/helpers.h"', public ] },
|
||||||
{ include: [ '"keysets_defs.generated.h"', private, '"nvim/api/private/defs.h"', public ] },
|
{ include: [ '"keysets_defs.generated.h"', private, '"nvim/api/private/defs.h"', public ] },
|
||||||
{ include: [ '"os/env.h.generated.h"', private, '"nvim/os/os.h"', public ] },
|
{ include: [ '"os/env.h.generated.h"', private, '"nvim/os/os.h"', public ] },
|
||||||
|
@ -915,6 +915,7 @@ def CheckIncludes(filename, lines, error):
|
|||||||
"src/nvim/ascii.h",
|
"src/nvim/ascii.h",
|
||||||
"src/nvim/assert.h",
|
"src/nvim/assert.h",
|
||||||
"src/nvim/autocmd.h",
|
"src/nvim/autocmd.h",
|
||||||
|
"src/nvim/autocmd_defs.h",
|
||||||
"src/nvim/base64.h",
|
"src/nvim/base64.h",
|
||||||
"src/nvim/buffer.h",
|
"src/nvim/buffer.h",
|
||||||
"src/nvim/buffer_defs.h",
|
"src/nvim/buffer_defs.h",
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// autocmd.c: Autocommand related functions
|
// autocmd.c: Autocommand related functions
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "klib/kvec.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/autocmd.h"
|
#include "nvim/autocmd.h"
|
||||||
|
@ -1,77 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
||||||
|
#include "nvim/autocmd_defs.h" // IWYU pragma: export
|
||||||
#include "nvim/buffer_defs.h"
|
#include "nvim/buffer_defs.h"
|
||||||
#include "nvim/cmdexpand_defs.h"
|
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/eval/typval_defs.h"
|
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/ex_cmds_defs.h"
|
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/macros.h"
|
#include "nvim/macros.h"
|
||||||
#include "nvim/regexp_defs.h"
|
#include "nvim/pos.h"
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
|
|
||||||
struct AutoPatCmd_S;
|
|
||||||
|
|
||||||
// event_T definition
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
|
||||||
# include "auevents_enum.generated.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Struct to save values in before executing autocommands for a buffer that is
|
|
||||||
// not the current buffer.
|
|
||||||
typedef struct {
|
|
||||||
buf_T *save_curbuf; ///< saved curbuf
|
|
||||||
int use_aucmd_win_idx; ///< index in aucmd_win[] if >= 0
|
|
||||||
handle_T save_curwin_handle; ///< ID of saved curwin
|
|
||||||
handle_T new_curwin_handle; ///< ID of new curwin
|
|
||||||
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
|
||||||
bufref_T new_curbuf; ///< new curbuf
|
|
||||||
char *globaldir; ///< saved value of globaldir
|
|
||||||
bool save_VIsual_active; ///< saved VIsual_active
|
|
||||||
int save_State; ///< saved State
|
|
||||||
} aco_save_T;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t refcount; ///< Reference count (freed when reaches zero)
|
|
||||||
char *pat; ///< Pattern as typed
|
|
||||||
regprog_T *reg_prog; ///< Compiled regprog for pattern
|
|
||||||
int group; ///< Group ID
|
|
||||||
int patlen; ///< strlen() of pat
|
|
||||||
int buflocal_nr; ///< !=0 for buffer-local AutoPat
|
|
||||||
char allow_dirs; ///< Pattern may match whole path
|
|
||||||
} AutoPat;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
AucmdExecutable exec; ///< Command or callback function
|
|
||||||
AutoPat *pat; ///< Pattern reference (NULL when autocmd was removed)
|
|
||||||
int64_t id; ///< ID used for uniquely tracking an autocmd
|
|
||||||
char *desc; ///< Description for the autocmd
|
|
||||||
sctx_T script_ctx; ///< Script context where it is defined
|
|
||||||
bool once; ///< "One shot": removed after execution
|
|
||||||
bool nested; ///< If autocommands nest here
|
|
||||||
} AutoCmd;
|
|
||||||
|
|
||||||
/// Struct used to keep status while executing autocommands for an event.
|
|
||||||
typedef struct AutoPatCmd_S AutoPatCmd;
|
|
||||||
struct AutoPatCmd_S {
|
|
||||||
AutoPat *lastpat; ///< Last matched AutoPat
|
|
||||||
size_t auidx; ///< Current autocmd index to execute
|
|
||||||
size_t ausize; ///< Saved AutoCmd vector size
|
|
||||||
char *fname; ///< Fname to match with
|
|
||||||
char *sfname; ///< Sfname to match with
|
|
||||||
char *tail; ///< Tail of fname
|
|
||||||
int group; ///< Group being used
|
|
||||||
event_T event; ///< Current event
|
|
||||||
sctx_T script_ctx; ///< Script context where it is defined
|
|
||||||
int arg_bufnr; ///< Initially equal to <abuf>, set to zero when buf is deleted
|
|
||||||
Object *data; ///< Arbitrary data
|
|
||||||
AutoPatCmd *next; ///< Chain of active apc-s for auto-invalidation
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef kvec_t(AutoCmd) AutoCmdVec;
|
|
||||||
|
|
||||||
// Set by the apply_autocmds_group function if the given event is equal to
|
// Set by the apply_autocmds_group function if the given event is equal to
|
||||||
// EVENT_FILETYPE. Used by the readfile function in order to determine if
|
// EVENT_FILETYPE. Used by the readfile function in order to determine if
|
||||||
// EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
|
// EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
|
||||||
|
71
src/nvim/autocmd_defs.h
Normal file
71
src/nvim/autocmd_defs.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "klib/kvec.h"
|
||||||
|
#include "nvim/api/private/defs.h"
|
||||||
|
#include "nvim/buffer_defs.h"
|
||||||
|
#include "nvim/eval/typval_defs.h"
|
||||||
|
#include "nvim/ex_cmds_defs.h"
|
||||||
|
#include "nvim/regexp_defs.h"
|
||||||
|
#include "nvim/types.h"
|
||||||
|
|
||||||
|
// event_T definition
|
||||||
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
# include "auevents_enum.generated.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Struct to save values in before executing autocommands for a buffer that is
|
||||||
|
/// not the current buffer.
|
||||||
|
typedef struct {
|
||||||
|
buf_T *save_curbuf; ///< saved curbuf
|
||||||
|
int use_aucmd_win_idx; ///< index in aucmd_win[] if >= 0
|
||||||
|
handle_T save_curwin_handle; ///< ID of saved curwin
|
||||||
|
handle_T new_curwin_handle; ///< ID of new curwin
|
||||||
|
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
||||||
|
bufref_T new_curbuf; ///< new curbuf
|
||||||
|
char *globaldir; ///< saved value of globaldir
|
||||||
|
bool save_VIsual_active; ///< saved VIsual_active
|
||||||
|
int save_State; ///< saved State
|
||||||
|
} aco_save_T;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t refcount; ///< Reference count (freed when reaches zero)
|
||||||
|
char *pat; ///< Pattern as typed
|
||||||
|
regprog_T *reg_prog; ///< Compiled regprog for pattern
|
||||||
|
int group; ///< Group ID
|
||||||
|
int patlen; ///< strlen() of pat
|
||||||
|
int buflocal_nr; ///< !=0 for buffer-local AutoPat
|
||||||
|
char allow_dirs; ///< Pattern may match whole path
|
||||||
|
} AutoPat;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
AucmdExecutable exec; ///< Command or callback function
|
||||||
|
AutoPat *pat; ///< Pattern reference (NULL when autocmd was removed)
|
||||||
|
int64_t id; ///< ID used for uniquely tracking an autocmd
|
||||||
|
char *desc; ///< Description for the autocmd
|
||||||
|
sctx_T script_ctx; ///< Script context where it is defined
|
||||||
|
bool once; ///< "One shot": removed after execution
|
||||||
|
bool nested; ///< If autocommands nest here
|
||||||
|
} AutoCmd;
|
||||||
|
|
||||||
|
/// Struct used to keep status while executing autocommands for an event.
|
||||||
|
typedef struct AutoPatCmd_S AutoPatCmd;
|
||||||
|
struct AutoPatCmd_S {
|
||||||
|
AutoPat *lastpat; ///< Last matched AutoPat
|
||||||
|
size_t auidx; ///< Current autocmd index to execute
|
||||||
|
size_t ausize; ///< Saved AutoCmd vector size
|
||||||
|
char *fname; ///< Fname to match with
|
||||||
|
char *sfname; ///< Sfname to match with
|
||||||
|
char *tail; ///< Tail of fname
|
||||||
|
int group; ///< Group being used
|
||||||
|
event_T event; ///< Current event
|
||||||
|
sctx_T script_ctx; ///< Script context where it is defined
|
||||||
|
int arg_bufnr; ///< Initially equal to <abuf>, set to zero when buf is deleted
|
||||||
|
Object *data; ///< Arbitrary data
|
||||||
|
AutoPatCmd *next; ///< Chain of active apc-s for auto-invalidation
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef kvec_t(AutoCmd) AutoCmdVec;
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "nvim/autocmd.h"
|
#include "nvim/autocmd_defs.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
// Values for in_cinkeys()
|
// Values for in_cinkeys()
|
||||||
|
@ -8,7 +8,10 @@ local aliases = auevents.aliases
|
|||||||
local enum_tgt = io.open(fileio_enum_file, 'w')
|
local enum_tgt = io.open(fileio_enum_file, 'w')
|
||||||
local names_tgt = io.open(names_file, 'w')
|
local names_tgt = io.open(names_file, 'w')
|
||||||
|
|
||||||
enum_tgt:write('typedef enum auto_event {')
|
enum_tgt:write([[
|
||||||
|
// IWYU pragma: private, include "nvim/autocmd_defs.h"
|
||||||
|
|
||||||
|
typedef enum auto_event {]])
|
||||||
names_tgt:write([[
|
names_tgt:write([[
|
||||||
static const struct event_name {
|
static const struct event_name {
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -34,6 +34,8 @@ static const uint8_t cmdidxs2[%u][%u] = {
|
|||||||
]], a_to_z, a_to_z)
|
]], a_to_z, a_to_z)
|
||||||
|
|
||||||
enumfile:write([[
|
enumfile:write([[
|
||||||
|
// IWYU pragma: private, include "nvim/ex_cmds_defs.h"
|
||||||
|
|
||||||
typedef enum CMD_index {
|
typedef enum CMD_index {
|
||||||
]])
|
]])
|
||||||
defsfile:write(string.format([[
|
defsfile:write(string.format([[
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "klib/kvec.h"
|
#include "klib/kvec.h"
|
||||||
#include "nvim/autocmd.h"
|
#include "nvim/autocmd_defs.h"
|
||||||
#include "nvim/cmdexpand_defs.h"
|
#include "nvim/cmdexpand_defs.h"
|
||||||
#include "nvim/eval/typval_defs.h"
|
#include "nvim/eval/typval_defs.h"
|
||||||
#include "nvim/ex_cmds_defs.h"
|
#include "nvim/ex_cmds_defs.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user