From 2783f4cc4a410cd3b73e8cdfbdf8c859c426c6c6 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 8 Mar 2022 09:45:43 +0530 Subject: feat(api): autocmd `group` can be either name or id (#17559) * feat(api): `group` can be either string or int This affects the following API functions: - `vim.api.nvim_create_autocmd` - `vim.api.nvim_get_autocmds` - `vim.api.nvim_do_autocmd` closes #17552 * refactor: add two maps for fast lookups * fix: delete augroup info from id->name map When in "stupid_legacy_mode", the value in name->id map would be updated to `AUGROUP_DELETED`, but the entry would still remain in id->name. This would create a problem in `augroup_name` function which would return the name of the augroup instead of `--DELETED--`. The id->name map is only used for fast loopup in `augroup_name` function so there's no point in keeping the entry of deleted augroup in it. Co-authored-by: TJ DeVries --- runtime/doc/api.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 73536d174a..eefe6e5a47 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3165,7 +3165,7 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* • create a |autocmd-buflocal| autocmd. • NOTE: Cannot be used with {pattern} - • group: (string) The augroup name + • group: (string|int) The augroup name or id • once: (boolean) - See |autocmd-once| • nested: (boolean) - See |autocmd-nested| • desc: (string) - Description of the autocmd @@ -3213,7 +3213,7 @@ nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* "*". • NOTE: Cannot be used with {buffer} - • group (string) - autocmd group name + • group (string|int) - autocmd group name or id • modeline (boolean) - Default true, see || @@ -3224,7 +3224,8 @@ nvim_get_autocmds({*opts}) *nvim_get_autocmds()* {opts} Optional Parameters: • event : Name or list of name of events to match against - • group (string): Name of group to match against + • group (string|int): Name or id of group to match + against • pattern: Pattern or list of patterns to match against. Cannot be used with {buffer} • buffer: Buffer number or list of buffer numbers -- cgit