diff options
Diffstat (limited to 'src/nvim/autocmd.h')
-rw-r--r-- | src/nvim/autocmd.h | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h index 259a56cf5c..8019cb7145 100644 --- a/src/nvim/autocmd.h +++ b/src/nvim/autocmd.h @@ -1,11 +1,12 @@ #pragma once #include <stdbool.h> -#include <stddef.h> -#include <stdint.h> +#include <stddef.h> // IWYU pragma: keep +#include <stdint.h> // IWYU pragma: keep +#include "klib/kvec.h" #include "nvim/api/private/defs.h" // IWYU pragma: keep -#include "nvim/autocmd_defs.h" // IWYU pragma: export +#include "nvim/autocmd_defs.h" // IWYU pragma: keep #include "nvim/buffer_defs.h" #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep @@ -27,18 +28,57 @@ EXTERN win_T *last_cursormoved_win INIT( = NULL); /// For CursorMoved event, only used when last_cursormoved_win == curwin EXTERN pos_T last_cursormoved INIT( = { 0, 0, 0 }); -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "autocmd.h.generated.h" -#endif +EXTERN bool autocmd_busy INIT( = false); ///< Is apply_autocmds() busy? +EXTERN int autocmd_no_enter INIT( = false); ///< Buf/WinEnter autocmds disabled +EXTERN int autocmd_no_leave INIT( = false); ///< Buf/WinLeave autocmds disabled +EXTERN bool did_filetype INIT( = false); ///< FileType event found +/// value for did_filetype when starting to execute autocommands +EXTERN bool keep_filetype INIT( = false); + +/// When deleting the current buffer, another one must be loaded. +/// If we know which one is preferred, au_new_curbuf is set to it. +EXTERN bufref_T au_new_curbuf INIT( = { NULL, 0, 0 }); + +// When deleting a buffer/window and autocmd_busy is true, do not free the +// buffer/window. but link it in the list starting with +// au_pending_free_buf/ap_pending_free_win, using b_next/w_next. +// Free the buffer/window when autocmd_busy is being set to false. +EXTERN buf_T *au_pending_free_buf INIT( = NULL); +EXTERN win_T *au_pending_free_win INIT( = NULL); + +EXTERN char *autocmd_fname INIT( = NULL); ///< fname for <afile> on cmdline +EXTERN bool autocmd_fname_full INIT( = false); ///< autocmd_fname is full path +EXTERN int autocmd_bufnr INIT( = 0); ///< fnum for <abuf> on cmdline +EXTERN char *autocmd_match INIT( = NULL); ///< name for <amatch> on cmdline +EXTERN bool did_cursorhold INIT( = false); ///< set when CursorHold t'gerd -#define AUGROUP_DEFAULT (-1) // default autocmd group -#define AUGROUP_ERROR (-2) // erroneous autocmd group -#define AUGROUP_ALL (-3) // all autocmd groups -#define AUGROUP_DELETED (-4) // all autocmd groups -// #define AUGROUP_NS -5 // TODO(tjdevries): Support namespaced based augroups +typedef struct { + win_T *auc_win; ///< Window used in aucmd_prepbuf(). When not NULL the + ///< window has been allocated. + bool auc_win_used; ///< This auc_win is being used. +} aucmdwin_T; -#define BUFLOCAL_PAT_LEN 25 +/// When executing autocommands for a buffer that is not in any window, a +/// special window is created to handle the side effects. When autocommands +/// nest we may need more than one. +EXTERN kvec_t(aucmdwin_T) aucmd_win_vec INIT( = KV_INITIAL_VALUE); +#define aucmd_win (aucmd_win_vec.items) +#define AUCMD_WIN_COUNT ((int)aucmd_win_vec.size) + +enum { + AUGROUP_DEFAULT = -1, ///< default autocmd group + AUGROUP_ERROR = -2, ///< erroneous autocmd group + AUGROUP_ALL = -3, ///< all autocmd groups + AUGROUP_DELETED = -4, ///< all autocmd groups + // AUGROUP_NS = -5, // TODO(tjdevries): Support namespaced based augroups +}; + +enum { BUFLOCAL_PAT_LEN = 25, }; /// Iterates over all the events for auto commands #define FOR_ALL_AUEVENTS(event) \ - for (event_T event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) // NOLINT + for (event_T event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1)) + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "autocmd.h.generated.h" +#endif |