refactor: use nvim.foo.bar format for autocommand groups

This commit is contained in:
Maria José Solano
2025-01-13 19:45:11 -08:00
parent 850084b519
commit 09e01437c9
28 changed files with 45 additions and 45 deletions

View File

@ -122,7 +122,7 @@ fully disable the mouse or popup-menu, do any of the following:
<
To remove the default popup-menu without disabling mouse: >vim
aunmenu PopUp
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
To remove only the "How-to disable mouse" menu item (and its separator): >vim
aunmenu PopUp.How-to\ disable\ mouse

View File

@ -21,7 +21,7 @@ local query_lint_on = vim.g.query_lint_on or { 'BufEnter', 'BufWrite' }
if not vim.b.disable_query_linter and #query_lint_on > 0 then
vim.api.nvim_create_autocmd(query_lint_on, {
group = vim.api.nvim_create_augroup('querylint', { clear = false }),
group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }),
buffer = buf,
callback = function()
vim.treesitter.query.lint(buf)

View File

@ -145,7 +145,7 @@ local vim9 = (function()
-- work well for calling ":source X" from within a vimscript/vim9script
-- function
M.make_source_cmd = function()
local group = vim.api.nvim_create_augroup('vim9script-source', {})
local group = vim.api.nvim_create_augroup('nvim.vim9script_source', {})
vim.api.nvim_create_autocmd('SourceCmd', {
pattern = '*.vim',
group = group,

View File

@ -151,7 +151,7 @@ function properties.trim_trailing_whitespace(bufnr, val)
)
if val == 'true' then
vim.api.nvim_create_autocmd('BufWritePre', {
group = 'editorconfig',
group = 'nvim.editorconfig',
buffer = bufnr,
callback = function()
local view = vim.fn.winsaveview()
@ -163,7 +163,7 @@ function properties.trim_trailing_whitespace(bufnr, val)
else
vim.api.nvim_clear_autocmds({
event = 'BufWritePre',
group = 'editorconfig',
group = 'nvim.editorconfig',
buffer = bufnr,
})
end
@ -180,7 +180,7 @@ function properties.insert_final_newline(bufnr, val)
local endofline = val == 'true'
if vim.bo[bufnr].endofline ~= endofline then
vim.api.nvim_create_autocmd('BufWritePre', {
group = 'editorconfig',
group = 'nvim.editorconfig',
buffer = bufnr,
once = true,
callback = function()

View File

@ -412,7 +412,7 @@ do
end
end
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim_popupmenu', {})
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim.popupmenu', {})
vim.api.nvim_create_autocmd('MenuPopup', {
pattern = '*',
group = nvim_popupmenu_augroup,
@ -429,7 +429,7 @@ end
--- Default autocommands. See |default-autocmds|
do
local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim_terminal', {})
local nvim_terminal_augroup = vim.api.nvim_create_augroup('nvim.terminal', {})
vim.api.nvim_create_autocmd('BufReadCmd', {
pattern = 'term://*',
group = nvim_terminal_augroup,
@ -509,14 +509,14 @@ do
vim.api.nvim_create_autocmd('CmdwinEnter', {
pattern = '[:>]',
desc = 'Limit syntax sync to maxlines=1 in the command window',
group = vim.api.nvim_create_augroup('nvim_cmdwin', {}),
group = vim.api.nvim_create_augroup('nvim.cmdwin', {}),
command = 'syntax sync minlines=1 maxlines=1',
})
vim.api.nvim_create_autocmd('SwapExists', {
pattern = '*',
desc = 'Skip the swapfile prompt when the swapfile is owned by a running Nvim process',
group = vim.api.nvim_create_augroup('nvim_swapfile', {}),
group = vim.api.nvim_create_augroup('nvim.swapfile', {}),
callback = function()
local info = vim.fn.swapinfo(vim.v.swapname)
local user = vim.uv.os_get_passwd().username
@ -543,7 +543,7 @@ do
end
if tty then
local group = vim.api.nvim_create_augroup('nvim_tty', {})
local group = vim.api.nvim_create_augroup('nvim.tty', {})
--- Set an option after startup (so that OptionSet is fired), but only if not
--- already set by the user.

View File

@ -356,7 +356,7 @@ local bufnr_and_namespace_cacher_mt = {
-- bufnr -> ns -> Diagnostic[]
local diagnostic_cache = {} --- @type table<integer,table<integer,vim.Diagnostic[]>>
do
local group = api.nvim_create_augroup('DiagnosticBufWipeout', {})
local group = api.nvim_create_augroup('nvim.diagnostic.buf_wipeout', {})
setmetatable(diagnostic_cache, {
--- @param t table<integer,vim.Diagnostic[]>
--- @param bufnr integer

View File

@ -841,7 +841,7 @@ local function buf_attach(bufnr)
attached_buffers[bufnr] = true
local uri = vim.uri_from_bufnr(bufnr)
local augroup = ('lsp_b_%d_save'):format(bufnr)
local augroup = ('nvim.lsp.b_%d_save'):format(bufnr)
local group = api.nvim_create_augroup(augroup, { clear = true })
api.nvim_create_autocmd('BufWritePre', {
group = group,

View File

@ -171,7 +171,7 @@ end
-- 1. Implement clearing `bufstate` and event hooks
-- when no clients in the buffer support the corresponding method.
-- 2. Then generalize this state management to other LSP modules.
local augroup_setup = api.nvim_create_augroup('vim_lsp_folding_range/setup', {})
local augroup_setup = api.nvim_create_augroup('nvim.lsp.folding_range.setup', {})
--- Initialize `bufstate` and event hooks, then request folding ranges.
--- Manage their lifecycle within this function.

View File

@ -30,7 +30,7 @@ local namespaces = setmetatable({}, {
---@private
M.__namespaces = namespaces
local augroup = api.nvim_create_augroup('vim_lsp_codelens', {})
local augroup = api.nvim_create_augroup('nvim.lsp.codelens', {})
api.nvim_create_autocmd('LspDetach', {
group = augroup,

View File

@ -630,7 +630,7 @@ local function enable_completions(client_id, bufnr, opts)
-- Set up autocommands.
local group =
api.nvim_create_augroup(string.format('vim/lsp/completion-%d', bufnr), { clear = true })
api.nvim_create_augroup(string.format('nvim.lsp.completion_%d', bufnr), { clear = true })
api.nvim_create_autocmd('CompleteDone', {
group = group,
buffer = bufnr,

View File

@ -5,7 +5,7 @@ local api = vim.api
local M = {}
local augroup = api.nvim_create_augroup('vim_lsp_diagnostic', {})
local augroup = api.nvim_create_augroup('nvim.lsp.diagnostic', {})
local DEFAULT_CLIENT_ID = -1

View File

@ -30,7 +30,7 @@ local bufstates = vim.defaulttable(function(_)
end)
local namespace = api.nvim_create_namespace('nvim.lsp.inlayhint')
local augroup = api.nvim_create_augroup('vim_lsp_inlayhint', {})
local augroup = api.nvim_create_augroup('nvim.lsp.inlayhint', {})
--- |lsp-handler| for the method `textDocument/inlayHint`
--- Store hints for a specific buffer and client

View File

@ -166,7 +166,7 @@ function STHighlighter.new(bufnr)
local self = setmetatable({}, { __index = STHighlighter })
self.bufnr = bufnr
self.augroup = api.nvim_create_augroup('vim_lsp_semantic_tokens:' .. bufnr, { clear = true })
self.augroup = api.nvim_create_augroup('nvim.lsp.semantic_tokens:' .. bufnr, { clear = true })
self.client_state = {}
STHighlighter.active[bufnr] = self

View File

@ -1357,7 +1357,7 @@ end
---@param bufnrs table list of buffers where the preview window will remain visible
---@see autocmd-events
local function close_preview_autocmd(events, winnr, bufnrs)
local augroup = api.nvim_create_augroup('preview_window_' .. winnr, {
local augroup = api.nvim_create_augroup('nvim.preview_window_' .. winnr, {
clear = true,
})
@ -1619,7 +1619,7 @@ function M.open_floating_preview(contents, syntax, opts)
api.nvim_buf_set_var(bufnr, 'lsp_floating_preview', floating_winnr)
end
local augroup_name = ('closing_floating_preview_%d'):format(floating_winnr)
local augroup_name = ('nvim.closing_floating_preview_%d'):format(floating_winnr)
local ok =
pcall(api.nvim_get_autocmds, { group = augroup_name, pattern = tostring(floating_winnr) })
if not ok then

View File

@ -1,5 +1,5 @@
local G = vim.lsp._snippet_grammar
local snippet_group = vim.api.nvim_create_augroup('vim/snippet', {})
local snippet_group = vim.api.nvim_create_augroup('nvim.snippet', {})
local snippet_ns = vim.api.nvim_create_namespace('nvim.snippet')
local hl_group = 'SnippetTabstop'
local jump_forward_key = '<tab>'

View File

@ -183,7 +183,7 @@ local M = {}
---@type table<integer,TS.FoldInfo>
local foldinfos = {}
local group = api.nvim_create_augroup('treesitter/fold', {})
local group = api.nvim_create_augroup('nvim.treesitter.fold', {})
--- Update the folds in the windows that contain the buffer and use expr foldmethod (assuming that
--- the user doesn't use different foldexpr for the same buffer).

View File

@ -442,7 +442,7 @@ function M.inspect_tree(opts)
end,
})
local group = api.nvim_create_augroup('treesitter/dev', {})
local group = api.nvim_create_augroup('nvim.treesitter.dev', {})
api.nvim_create_autocmd('CursorMoved', {
group = group,
@ -633,7 +633,7 @@ function M.edit_query(lang)
-- can infer the language later.
api.nvim_buf_set_name(query_buf, string.format('%s/query_editor.scm', lang))
local group = api.nvim_create_augroup('treesitter/dev-edit', {})
local group = api.nvim_create_augroup('nvim.treesitter.dev_edit', {})
api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, {
group = group,
buffer = query_buf,

View File

@ -289,7 +289,7 @@ end, false)
api.nvim_create_autocmd('OptionSet', {
pattern = { 'runtimepath' },
group = api.nvim_create_augroup('ts_query_cache_reset', { clear = true }),
group = api.nvim_create_augroup('nvim.treesitter.query_cache_reset', { clear = true }),
callback = function()
M.get:clear()
end,

View File

@ -1,4 +1,4 @@
local group = vim.api.nvim_create_augroup('editorconfig', {})
local group = vim.api.nvim_create_augroup('nvim.editorconfig', {})
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead', 'BufFilePost' }, {
group = group,
callback = function(args)

View File

@ -24,7 +24,7 @@ end, {
end,
})
local augroup = vim.api.nvim_create_augroup('man', {})
local augroup = vim.api.nvim_create_augroup('nvim.man', {})
vim.api.nvim_create_autocmd('BufReadCmd', {
group = augroup,

View File

@ -32,7 +32,7 @@ describe('default', function()
describe('popupmenu', function()
it('can be disabled by user', function()
n.clear {
args = { '+autocmd! nvim_popupmenu', '+aunmenu PopUp' },
args = { '+autocmd! nvim.popupmenu', '+aunmenu PopUp' },
}
local screen = Screen.new(40, 8)
n.insert([[

View File

@ -173,7 +173,7 @@ describe('swapfile detection', function()
local screen2 = Screen.new(256, 40)
screen2._default_attr_ids = nil
exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog).
command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
-- With shortmess+=F
command('set shortmess+=F')
@ -277,7 +277,7 @@ describe('swapfile detection', function()
set_session(nvim1)
screen:attach()
exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog).
command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
feed(':split Xfile1\n')
-- The default SwapExists handler does _not_ skip this prompt.
screen:expect({
@ -296,7 +296,7 @@ describe('swapfile detection', function()
set_session(nvim2)
screen:attach()
exec(init)
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog).
command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
command('set more')
command('au bufadd * let foo_w = wincol()')
feed(':e Xfile1<CR>')
@ -327,7 +327,7 @@ describe('swapfile detection', function()
exec(init)
if not swapexists then
command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog).
command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog).
end
command('set nohidden')

View File

@ -351,7 +351,7 @@ describe(':terminal buffer', function()
end)
it('TermRequest synchronization #27572', function()
command('autocmd! nvim_terminal TermRequest')
command('autocmd! nvim.terminal TermRequest')
local term = exec_lua([[
_G.input = {}
local term = vim.api.nvim_open_term(0, {

View File

@ -176,7 +176,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('with no argument, acts like jobstart(…,{term=true})', function()
command('autocmd! nvim_terminal TermClose')
command('autocmd! nvim.terminal TermClose')
feed_command('terminal')
screen:expect([[
^ready $ |
@ -246,7 +246,7 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('ignores writes if the backing stream closes', function()
command('autocmd! nvim_terminal TermClose')
command('autocmd! nvim.terminal TermClose')
feed_command('terminal')
feed('iiXXXXXXX')
poke_eventloop()
@ -258,14 +258,14 @@ local function test_terminal_with_fake_shell(backslash)
end)
it('works with findfile()', function()
command('autocmd! nvim_terminal TermClose')
command('autocmd! nvim.terminal TermClose')
feed_command('terminal')
eq('term://', string.match(eval('bufname("%")'), '^term://'))
eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")'))
end)
it('works with :find', function()
command('autocmd! nvim_terminal TermClose')
command('autocmd! nvim.terminal TermClose')
feed_command('terminal')
screen:expect([[
^ready $ |

View File

@ -644,7 +644,7 @@ describe('TUI', function()
aunmenu PopUp
" Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR>

View File

@ -1094,7 +1094,7 @@ describe('ext_multigrid', function()
end)
it('supports mouse', function()
command('autocmd! nvim_popupmenu') -- Delete the default MenuPopup event handler.
command('autocmd! nvim.popupmenu') -- Delete the default MenuPopup event handler.
insert('some text\nto be clicked')
screen:expect{grid=[[
## grid 1

View File

@ -841,7 +841,7 @@ describe('ui/ext_popupmenu', function()
aunmenu PopUp
" Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
menu PopUp.baz :let g:menustr = 'baz'<CR>
@ -4089,7 +4089,7 @@ describe('builtin popupmenu', function()
set mouse=a mousemodel=popup
" Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
aunmenu PopUp
menu PopUp.foo :let g:menustr = 'foo'<CR>
menu PopUp.bar :let g:menustr = 'bar'<CR>
@ -4946,7 +4946,7 @@ describe('builtin popupmenu', function()
it(':popup command', function()
exec([[
" Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
func ChangeMenu()
aunmenu PopUp.&Paste
@ -5106,7 +5106,7 @@ describe('builtin popupmenu', function()
exec([[
set mousemodel=popup_setpos
" Delete the default MenuPopup event handler.
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
aunmenu *
source $VIMRUNTIME/menu.vim
call setline(1, join(range(20)))

View File

@ -65,7 +65,7 @@ mapclear
mapclear!
aunmenu *
tlunmenu *
autocmd! nvim_popupmenu
autocmd! nvim.popupmenu
" Undo the 'grepprg' and 'grepformat' setting in _defaults.lua.
set grepprg& grepformat&