nx.augroup
nx.augroup.create(name, opts)
nx.augroup.create(name, opts) -> id [alias nvim_create_augroup]: define (or look
up) an autocommand group and return its numeric id. An augroup is just a named
bucket for autocmds: pass the returned id as opts.group to nx.autocmd.create so
the whole set can be cleared and re-registered as a unit.
Arguments:
name— the group name (string). Calling create again with the same name returns the SAME id; the id is stable across recreation, so it’s safe to store.opts.clear— when the group already exists, whether to remove its existing autocmds first. Defaults to TRUE (matching neovim). This is what makes re-sourcing your config idempotent: a config that doesnx.augroup.create("MyGroup")on every load clears the previous run’s autocmds instead of double-registering them. Pass{ clear = false }to keep them (the augroup-block /:augroupex-command path uses this to append).
The idiomatic pattern — own a group, then hang autocmds off it:
local grp = nx.augroup.create("MyConfig") -- clears on re-source
nx.autocmd.create("BufEnter", {
group = grp, -- numeric id, or "MyConfig"
callback = function(ev) nx.notify("entered " .. (ev.file or "[No Name]")) end,
})
Defined in autocmd.lua.