mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
feat(api): add group_name
to nvim_get_autocmds
(#18440)
(cherry picked from commit 96289f2416
)
Co-authored-by: Famiu Haque <famiuhaque@protonmail.com>
This commit is contained in:
![41898282+github-actions[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
e28799f2d8
commit
b7a5278249
@@ -3385,6 +3385,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.
|
||||
|
@@ -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) {
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user