neovim

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

autocmd_defs.h (3053B)


      1 #pragma once
      2 
      3 #include <stdbool.h>
      4 #include <stddef.h>
      5 #include <stdint.h>
      6 
      7 #include "nvim/buffer_defs.h"
      8 #include "nvim/ex_cmds_defs.h"
      9 
     10 #include "auevents_enum.generated.h"
     11 
     12 /// Struct to save values in before executing autocommands for a buffer that is
     13 /// not the current buffer.
     14 typedef struct {
     15  int use_aucmd_win_idx;          ///< index in aucmd_win[] if >= 0
     16  handle_T save_curwin_handle;    ///< ID of saved curwin
     17  handle_T new_curwin_handle;     ///< ID of new curwin
     18  handle_T save_prevwin_handle;   ///< ID of saved prevwin
     19  bufref_T new_curbuf;            ///< new curbuf
     20  char *tp_localdir;              ///< saved value of tp_localdir
     21  char *globaldir;                ///< saved value of globaldir
     22  bool save_VIsual_active;        ///< saved VIsual_active
     23  int save_prompt_insert;         ///< saved b_prompt_insert
     24 } aco_save_T;
     25 
     26 typedef struct {
     27  size_t refcount;          ///< Reference count (freed when reaches zero)
     28  char *pat;                ///< Pattern as typed
     29  regprog_T *reg_prog;      ///< Compiled regprog for pattern
     30  int group;                ///< Group ID
     31  int patlen;               ///< strlen() of pat
     32  int buflocal_nr;          ///< !=0 for buffer-local AutoPat
     33  char allow_dirs;          ///< Pattern may match whole path
     34 } AutoPat;
     35 
     36 typedef struct {
     37  AutoPat *pat;             ///< Pattern reference (NULL when autocmd was removed)
     38  int64_t id;               ///< ID used for uniquely tracking an autocmd
     39  char *desc;               ///< Description for the autocmd
     40  char *handler_cmd;        ///< Handler Ex command (NULL if handler is a function).
     41  Callback handler_fn;      ///< Handler callback (ignored if `handler_cmd` is not NULL).
     42  sctx_T script_ctx;        ///< Script context where it is defined
     43  bool once;                ///< "One shot": removed after execution
     44  bool nested;              ///< If autocommands nest here
     45 } AutoCmd;
     46 
     47 /// Struct used to keep status while executing autocommands for an event.
     48 typedef struct AutoPatCmd_S AutoPatCmd;
     49 struct AutoPatCmd_S {
     50  AutoPat *lastpat;         ///< Last matched AutoPat
     51  size_t auidx;             ///< Current autocmd index to execute
     52  size_t ausize;            ///< Saved AutoCmd vector size
     53  char *afile_orig;         ///< Unexpanded <afile>
     54  char *fname;              ///< Fname to match with
     55  char *sfname;             ///< Sfname to match with
     56  char *tail;               ///< Tail of fname
     57  int group;                ///< Group being used
     58  event_T event;            ///< Current event
     59  sctx_T script_ctx;        ///< Script context where it is defined
     60  int arg_bufnr;            ///< Initially equal to <abuf>, set to zero when buf is deleted
     61  Object *data;             ///< Arbitrary data
     62  AutoPatCmd *next;         ///< Chain of active apc-s for auto-invalidation
     63 };
     64 
     65 typedef kvec_t(AutoCmd) AutoCmdVec;
     66 
     67 typedef struct {
     68  event_T event;
     69  char *fname;
     70  char *fname_io;
     71  Buffer buf;
     72  int group;
     73  exarg_T *eap;
     74  Object *data;
     75 } AutoCmdEvent;  // Used for "deferred" events, but can represent any event.