diff options
author | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-05 21:00:47 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-05 23:17:36 +0600 |
commit | 96289f24169281da419e8ce1078705258db3229b (patch) | |
tree | 8300632f4e9b959dcf0be50bd5014d8813533089 | |
parent | 82c7a82c3585100e73e154c49e3e002b7dc35437 (diff) | |
download | rneovim-96289f24169281da419e8ce1078705258db3229b.tar.gz rneovim-96289f24169281da419e8ce1078705258db3229b.tar.bz2 rneovim-96289f24169281da419e8ce1078705258db3229b.zip |
feat(api): add `group_name` to `nvim_get_autocmds`
-rw-r--r-- | runtime/doc/api.txt | 1 | ||||
-rw-r--r-- | src/nvim/api/autocmd.c | 2 | ||||
-rw-r--r-- | test/functional/api/autocmd_spec.lua | 3 |
3 files changed, 6 insertions, 0 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index d4477df803..1f97f38b54 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3508,6 +3508,7 @@ nvim_get_autocmds({*opts}) *nvim_get_autocmds()* • id (number): the autocommand id (only when defined with the API). • group (integer): the autocommand group id. + • group_name (string): the autocommand group name. • desc (string): the autocommand description. • event (string): the autocommand event. • command (string): the autocommand command. diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index 010c03e505..4645b77a1c 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -64,6 +64,7 @@ static int64_t next_autocmd_id = 1; /// containing the following fields: /// - id (number): the autocommand id (only when defined with the API). /// - group (integer): the autocommand group id. +/// - group_name (string): the autocommand group name. /// - desc (string): the autocommand description. /// - event (string): the autocommand event. /// - command (string): the autocommand command. @@ -269,6 +270,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err) if (ap->group != AUGROUP_DEFAULT) { PUT(autocmd_info, "group", INTEGER_OBJ(ap->group)); + PUT(autocmd_info, "group_name", CSTR_TO_OBJ(augroup_name(ap->group))); } if (ac->id > 0) { diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index a30af63ba1..41de308a2c 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -444,6 +444,7 @@ describe('autocmd api', function() eq(1, #aus) eq([[:echo "GroupOne:1"]], aus[1].command) + eq("GroupOne", aus[1].group_name) end) it('should return only the group specified, multiple values', function() @@ -454,7 +455,9 @@ describe('autocmd api', function() eq(2, #aus) eq([[:echo "GroupTwo:2"]], aus[1].command) + eq("GroupTwo", aus[1].group_name) eq([[:echo "GroupTwo:3"]], aus[2].command) + eq("GroupTwo", aus[2].group_name) end) end) |