Listing Auto-Commands

Listing Auto-Commands

:autocmd
vim.api.nvim_get_autocmds({opts})

where opts is a table containing one or more of:

--opts
{
group, -- optional string or integer, which group(s) to include
event, -- optional string or list of strings, which event(s) to include
-- 0 or 1 of the following:
pattern, -- optional string or list of strings, pattern filter
-- for buffer-local auto-commands:
buffer -- optional integer or list of integers
}

Note that pattern and buffer are mutually-exclusive, if either is present the other cannot.

This functions returns a list of tables, where each table represents an auto-command that matched the filter(s) specified in opts, and table contains the following keys:

{
id, -- integer, auto-command id
group, -- integer, group id
group_name, -- string, auto-group name
desc, -- string, auto-command description
event, -- string, event name
command, -- string, command or nil if Lua callback
callback, -- optional function or string
once, -- boolean, whether the auto-command is fired only once (default false)
pattern, -- string, the auto-command pattern
buflocal, -- boolean, true if the auto-command is buffer local
buffer -- integer, the buffer number
}