Change menu item shorthand syntax

I'm changing the syntax a bit because I want it to be more general in
the future.
This commit is contained in:
James Westman 2021-11-28 22:31:33 -06:00
parent 2130c78da9
commit 878ff1b37b
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
3 changed files with 22 additions and 13 deletions

View file

@ -95,19 +95,28 @@ menu_item_shorthand = Group(
Sequence(
Keyword("item"),
UseLiteral("tag", "item"),
OpenParen(),
Group(
MenuAttribute,
Sequence(UseLiteral("name", "label"), value),
),
Optional(Group(
MenuAttribute,
Sequence(UseLiteral("name", "action"), value),
Optional(Sequence(
Comma(),
Optional(Sequence(
Group(
MenuAttribute,
Sequence(UseLiteral("name", "action"), value),
),
Optional(Sequence(
Comma(),
Group(
MenuAttribute,
Sequence(UseLiteral("name", "icon"), value),
),
))
))
)),
Optional(Group(
MenuAttribute,
Sequence(UseLiteral("name", "icon"), value),
)),
StmtEnd().expected("`;`"),
CloseParen().expected("')'"),
)
)
@ -163,7 +172,7 @@ def menu_content_completer(ast_node, match_variables):
)
yield Completion(
"item (shorthand)", CompletionItemKind.Snippet,
snippet='item _("${1:Label}") "${2:action-name}" "${3:icon-name}";'
snippet='item (_("${1:Label}"), "${2:action-name}", "${3:icon-name}");'
)
yield Completion(