neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

autocmd.h (3241B)


      1 #pragma once
      2 
      3 #include <stdbool.h>
      4 #include <stddef.h>  // IWYU pragma: keep
      5 #include <stdint.h>  // IWYU pragma: keep
      6 
      7 #include "klib/kvec.h"
      8 #include "nvim/api/private/defs.h"  // IWYU pragma: keep
      9 #include "nvim/autocmd_defs.h"  // IWYU pragma: keep
     10 #include "nvim/buffer_defs.h"
     11 #include "nvim/cmdexpand_defs.h"  // IWYU pragma: keep
     12 #include "nvim/eval/typval_defs.h"  // IWYU pragma: keep
     13 #include "nvim/event/defs.h"
     14 #include "nvim/ex_cmds_defs.h"  // IWYU pragma: keep
     15 #include "nvim/macros_defs.h"
     16 #include "nvim/pos_defs.h"
     17 #include "nvim/types_defs.h"
     18 
     19 /// For CursorMoved event
     20 EXTERN win_T *last_cursormoved_win INIT( = NULL);
     21 /// For CursorMoved event, only used when last_cursormoved_win == curwin
     22 EXTERN pos_T last_cursormoved INIT( = { 0, 0, 0 });
     23 
     24 EXTERN bool autocmd_busy INIT( = false);     ///< Is apply_autocmds() busy?
     25 EXTERN int autocmd_no_enter INIT( = false);  ///< Buf/WinEnter autocmds disabled
     26 EXTERN int autocmd_no_leave INIT( = false);  ///< Buf/WinLeave autocmds disabled
     27 
     28 /// When deleting the current buffer, another one must be loaded.
     29 /// If we know which one is preferred, au_new_curbuf is set to it.
     30 EXTERN bufref_T au_new_curbuf INIT( = { NULL, 0, 0 });
     31 
     32 // When deleting a buffer/window and autocmd_busy is true, do not free the
     33 // buffer/window. but link it in the list starting with
     34 // au_pending_free_buf/ap_pending_free_win, using b_next/w_next.
     35 // Free the buffer/window when autocmd_busy is being set to false.
     36 EXTERN buf_T *au_pending_free_buf INIT( = NULL);
     37 EXTERN win_T *au_pending_free_win INIT( = NULL);
     38 
     39 EXTERN char *autocmd_fname INIT( = NULL);       ///< fname for <afile> on cmdline
     40 EXTERN bool autocmd_fname_full INIT( = false);  ///< autocmd_fname is full path
     41 EXTERN int autocmd_bufnr INIT( = 0);            ///< fnum for <abuf> on cmdline
     42 EXTERN char *autocmd_match INIT( = NULL);       ///< name for <amatch> on cmdline
     43 EXTERN bool did_cursorhold INIT( = true);       ///< set when CursorHold t'gerd
     44 
     45 typedef struct {
     46  win_T *auc_win;     ///< Window used in aucmd_prepbuf().  When not NULL the
     47                      ///< window has been allocated.
     48  bool auc_win_used;  ///< This auc_win is being used.
     49 } aucmdwin_T;
     50 
     51 /// When executing autocommands for a buffer that is not in any window, a
     52 /// special window is created to handle the side effects.  When autocommands
     53 /// nest we may need more than one.
     54 EXTERN kvec_t(aucmdwin_T) aucmd_win_vec INIT( = KV_INITIAL_VALUE);
     55 #define aucmd_win (aucmd_win_vec.items)
     56 #define AUCMD_WIN_COUNT ((int)aucmd_win_vec.size)
     57 
     58 enum {
     59  AUGROUP_DEFAULT = -1,  ///< default autocmd group
     60  AUGROUP_ERROR   = -2,  ///< erroneous autocmd group
     61  AUGROUP_ALL     = -3,  ///< all autocmd groups
     62  AUGROUP_DELETED = -4,  ///< all autocmd groups
     63  // AUGROUP_NS      = -5,  // TODO(tjdevries): Support namespaced based augroups
     64 };
     65 
     66 enum { BUFLOCAL_PAT_LEN = 25, };
     67 
     68 /// Iterates over all the events for auto commands
     69 #define FOR_ALL_AUEVENTS(event) \
     70  for (event_T event = (event_T)0; (int)event < (int)NUM_EVENTS; event = (event_T)((int)event + 1))
     71 
     72 /// Stores events for execution until a known safe state.
     73 /// This should be the default for all new autocommands.
     74 EXTERN MultiQueue *deferred_events INIT( = NULL);
     75 
     76 #include "autocmd.h.generated.h"