mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 22:10:45 +00:00
docs(api): nvim_exec_autocmds() default "pattern"
Problem: nvim_exec_autocmds() documentation incorrectly describes the default for "pattern" as *, when it's actually the current file name (like :doautocmd). Solution: correct it. Add a test.
This commit is contained in:
@@ -2227,8 +2227,8 @@ nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()*
|
||||
• {opts} (`vim.api.keyset.exec_autocmds`) Optional filters:
|
||||
• group (`string|integer?`) Group name or id to match
|
||||
against. |autocmd-groups|.
|
||||
• pattern (`string|array?`, default: "*") |autocmd-pattern|.
|
||||
Not allowed with {buffer}.
|
||||
• pattern (`string|array?`, default: current file name)
|
||||
|autocmd-pattern|. Not allowed with {buffer}.
|
||||
• buffer (`integer?`) Buffer id |autocmd-buflocal|. Not
|
||||
allowed with {pattern}.
|
||||
• modeline (`boolean?`, default: true) Process the modeline
|
||||
|
||||
2
runtime/lua/vim/_meta/api.lua
generated
2
runtime/lua/vim/_meta/api.lua
generated
@@ -1224,7 +1224,7 @@ function vim.api.nvim_exec2(src, opts) end
|
||||
--- @param event vim.api.keyset.events|vim.api.keyset.events[] Event(s) to execute.
|
||||
--- @param opts vim.api.keyset.exec_autocmds Optional filters:
|
||||
--- - group (`string|integer?`) Group name or id to match against. `autocmd-groups`.
|
||||
--- - pattern (`string|array?`, default: "*") `autocmd-pattern`. Not allowed with {buffer}.
|
||||
--- - pattern (`string|array?`, default: current file name) `autocmd-pattern`. Not allowed with {buffer}.
|
||||
--- - buffer (`integer?`) Buffer id `autocmd-buflocal`. Not allowed with {pattern}.
|
||||
--- - modeline (`boolean?`, default: true) Process the modeline after the autocommands
|
||||
--- [<nomodeline>].
|
||||
|
||||
@@ -657,7 +657,7 @@ void nvim_del_augroup_by_name(String name, Error *err)
|
||||
/// @param event Event(s) to execute.
|
||||
/// @param opts Optional filters:
|
||||
/// - group (`string|integer?`) Group name or id to match against. |autocmd-groups|.
|
||||
/// - pattern (`string|array?`, default: "*") |autocmd-pattern|. Not allowed with {buffer}.
|
||||
/// - pattern (`string|array?`, default: current file name) |autocmd-pattern|. Not allowed with {buffer}.
|
||||
/// - buffer (`integer?`) Buffer id |autocmd-buflocal|. Not allowed with {pattern}.
|
||||
/// - modeline (`boolean?`, default: true) Process the modeline after the autocommands
|
||||
/// [<nomodeline>].
|
||||
|
||||
@@ -1053,6 +1053,14 @@ describe('autocmd api', function()
|
||||
|
||||
api.nvim_exec_autocmds('BufReadPre', { pattern = { 'foo', 'bar', 'baz', 'frederick' } })
|
||||
eq(22, api.nvim_get_var('autocmd_executed'))
|
||||
|
||||
eq('', api.nvim_buf_get_name(0))
|
||||
api.nvim_exec_autocmds({ 'BufReadPre', 'BufReadPost' }, {})
|
||||
eq(23, api.nvim_get_var('autocmd_executed'))
|
||||
|
||||
api.nvim_buf_set_name(0, 'bar')
|
||||
api.nvim_exec_autocmds({ 'BufReadPre', 'BufReadPost' }, {})
|
||||
eq(34, api.nvim_get_var('autocmd_executed'))
|
||||
end)
|
||||
|
||||
it('can pass the buffer', function()
|
||||
|
||||
Reference in New Issue
Block a user