robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0f1e0a7900
master
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 12typedef struct { 13size_t refcount ;///< Reference count (freed when reaches zero) 14char * pat ;///< Pattern as typed 15regprog_T * reg_prog ;///< Compiled regprog for pattern 16int group ;///< Group ID 17int patlen ;///< strlen() of pat 18int buflocal_nr ;///< !=0 for buffer-local AutoPat 19char allow_dirs ;///< Pattern may match whole path 20}AutoPat ; 21 22typedef struct { 23AutoPat * pat ;///< Pattern reference (NULL when autocmd was removed) 24int64_t id ;///< ID used for uniquely tracking an autocmd 25char * desc ;///< Description for the autocmd 26char * handler_cmd ;///< Handler Ex command (NULL if handler is a function). 27Callback handler_fn ;///< Handler callback (ignored if `handler_cmd` is not NULL). 28sctx_T script_ctx ;///< Script context where it is defined 29bool once ;///< "One shot": removed after execution 30bool nested ;///< If autocommands nest here 31}AutoCmd ; 32 33/// Struct used to keep status while executing autocommands for an event. 34typedef struct AutoPatCmd_S AutoPatCmd ; 35struct AutoPatCmd_S { 36AutoPat * lastpat ;///< Last matched AutoPat 37size_t auidx ;///< Current autocmd index to execute 38size_t ausize ;///< Saved AutoCmd vector size 39char * afile_orig ;///< Unexpanded <afile> 40char * fname ;///< Fname to match with 41char * sfname ;///< Sfname to match with 42char * tail ;///< Tail of fname 43int group ;///< Group being used 44event_T event ;///< Current event 45sctx_T script_ctx ;///< Script context where it is defined 46int arg_bufnr ;///< Initially equal to <abuf>, set to zero when buf is deleted 47Object * data ;///< Arbitrary data 48AutoPatCmd * next ;///< Chain of active apc-s for auto-invalidation 49}; 50 51typedef kvec_t (AutoCmd )AutoCmdVec ; 52 53typedef struct { 54event_T event ; 55char * fname ; 56char * fname_io ; 57Buffer buf ; 58int group ; 59exarg_T * eap ; 60Object * data ; 61}AutoCmdEvent ;// Used for "deferred" events, but can represent any event.