Skip to content

Commit b63be26

Browse files
committed
feat: support optional arguments {arg}?
For neovim/neovim#27644
1 parent 40fcd50 commit b63be26

File tree

6 files changed

+4157
-4042
lines changed

6 files changed

+4157
-4042
lines changed

corpus/arguments.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ argument: {arg}
55
tuple: {arg,arg}
66
keycode: CTRL-R {CTRL-R} {register CTRL-F}
77
list of { uri:string, name: string } tables
8+
optional argument: {arg}?
89

910

1011
--------------------------------------------------------------------------------
@@ -38,7 +39,12 @@ list of { uri:string, name: string } tables
3839
(word)
3940
(word)
4041
(word)
41-
(word))))
42+
(word))
43+
(line
44+
(word)
45+
(word)
46+
(argument
47+
(word)))))
4248

4349
================================================================================
4450
multiple arguments on the same line
@@ -211,3 +217,4 @@ EXTERNAL *netrw-externapp* {{{2
211217
(tag
212218
(word))
213219
(word)))))
220+

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ module.exports = grammar({
216216
// Inline code (may contain whitespace!): `foo bar`
217217
codespan: ($) => _word($, /[^``\n]+/, '`', '`'),
218218
// Argument: {arg} (no whitespace allowed)
219-
argument: ($) => _word($, /[^}\n\t ]+/, '{', '}'),
219+
argument: ($) => seq(_word($, /[^}\n\t ]+/, '{', '}'), optional(token.immediate('?'))),
220220
},
221221
});
222222

src/grammar.json

Lines changed: 39 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)