Customize Autocommands
A large part of configuring Neovim is the use of autocommands and autocmd groups (augroups). AstroNvim makes it easy to configure autocommands through AstroCore and AstroLSP. AstroCore handles the general autocommands that are applied on startup where AstroLSP handles autocommands that are set when a language server attaches. This page goes over how to customize these mappings to fit your needs.
Add Custom Autocommands
These tables are a direct conversion to the vim.api.nvim_create_autocmd({event}, {autocmd_opts})
and vim.api.nvim_create_augroup({name}, {augroup_opts})
Lua APIs. The key into the table is the {name}
field for creating an augroup
, and the value is a list-like table where each element is the {autocmds_opts}
table with the {event}
in as a value with the key "event"
. Also AstroLSP supports adding a cond
key which can dictate when the autocmd should be created (this is described in detail in the AstroLSP plugin configuration documentation) Here is a simple plugin specification example of setting both core and LSP autocmds:
Removing Built-in Autocommands
AstroNvim comes with a number of autocommands for improving the out of the box experience. This includes things such as mapping q
to buffer close in non-editable buffers, disabling features for large buffers, or flashing the highlight of text on copy. These can be easily disabled similar to how mappings are disabled, by setting the augroup
name to false
.
For example, if you want to disable the autocommand that highlights yanked text (using vim.highlight.on_yank
) you can add the following plugin spec: