docs: use "ev" convention in event-handlers

Problem:
In autocmd examples, using "args" as the event-object name is vague and
may be confused with a user-command.

Solution:
Use "ev" as the conventional event-object name.
This commit is contained in:
Justin M. Keyes
2026-03-11 14:25:12 +01:00
parent bc67976c95
commit 7ea148a1dc
35 changed files with 191 additions and 205 deletions

View File

@@ -7,24 +7,24 @@ vim.api.nvim_create_augroup('filetypedetect', { clear = false })
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, {
group = 'filetypedetect',
callback = function(args)
if not vim.api.nvim_buf_is_valid(args.buf) then
callback = function(ev)
if not vim.api.nvim_buf_is_valid(ev.buf) then
return
end
local ft, on_detect, is_fallback = vim.filetype.match({
-- The unexpanded file name is needed here. #27914
-- However, bufname() can't be used, as it doesn't work with :doautocmd. #31306
filename = args.file,
buf = args.buf,
filename = ev.file,
buf = ev.buf,
})
if ft then
-- on_detect is called before setting the filetype so that it can set any buffer local
-- variables that may be used the filetype's ftplugin
if on_detect then
on_detect(args.buf)
on_detect(ev.buf)
end
vim._with({ buf = args.buf }, function()
vim._with({ buf = ev.buf }, function()
vim.api.nvim_cmd({
cmd = 'setf',
args = (is_fallback and { 'FALLBACK', ft } or { ft }),