Yes, you can, by filtering the results of the taglist()
function, which give you a convenient programmatic access to the tags database.
:echo map(filter(taglist('.*'), 'has_key(v:val, "enum") && v:val.enum ==# "fruit"'), 'v:val.name')
['APPLE', 'ORANGE', 'PEAR']
What this does is:
- Get all tags (
.*
regular expression) - Keep (
filter()
) all tags that have (has_key()
) anenum
attribute, and whose name is exactly (==#
)fruit
. - From the resulting objects, select (
map()
) only thename
attribute.