Skip to content

Commit

Permalink
optional [argument]
Browse files Browse the repository at this point in the history
fix #1
  • Loading branch information
justinmk committed Jun 25, 2023
1 parent 8c0469d commit 985da98
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
6 changes: 2 additions & 4 deletions corpus/arguments.txt → corpus/argument.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ nvim_buf_detach_event[{buf}]
(word))
(line
(word)
(word)
(argument
(word))
(word))))
(optional_arg
(word)))))

================================================================================
NOT an argument
Expand Down
40 changes: 40 additions & 0 deletions corpus/argument_optional.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
================================================================================
optional [argument]
================================================================================
:ar[gs]! [++opt] [+cmd] {arglist} *:args_f!*
:[count]arge[dit][!] [++opt] [+cmd] {name} ..


--------------------------------------------------------------------------------

(help_file
(block
(line
(word)
(optional_arg
(word))
(word)
(optional_arg
(word))
(optional_arg
(word))
(argument
(word))
(tag
(word)))
(line
(word)
(optional_arg
(word))
(word)
(optional_arg
(word))
(optional_arg
(word))
(optional_arg
(word))
(optional_arg
(word))
(argument
(word))
(word))))
4 changes: 2 additions & 2 deletions corpus/codeblock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ codeblock stop and start on same line
(line
(word)
(word)
(word)
(word))
(optional_arg
(word)))
(line
(argument
(word))))
Expand Down
4 changes: 2 additions & 2 deletions corpus/taglink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Hello |world| hello
(taglink
(word))
(word)
(word)
(word)
(optional_arg
(word))
(word))
(line
(taglink
Expand Down
4 changes: 1 addition & 3 deletions corpus/url.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ markdown: [https://neovim.io/doc/user/#yay](https://neovim.io/doc/user/#yay).
(word))
(line
(word)
(word)
(url
(optional_arg
(word))
(word)
(word)
(url
(word))
(word))))
3 changes: 3 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = grammar({
$.taglink,
$.codespan,
$.argument,
$.optional_arg,
$.keycode,
),

Expand Down Expand Up @@ -210,6 +211,8 @@ module.exports = grammar({
codespan: ($) => _word($, /[^``\n]+/, '`', '`'),
// Argument: {arg} (no whitespace allowed)
argument: ($) => _word($, /[^}\n\t ]+/, '{', '}'),
// Optional argument: [arg] (no whitespace allowed)
optional_arg: ($) => _word($, /[^\]\n\t ]+/, '[', ']'),
},
});

Expand Down

0 comments on commit 985da98

Please sign in to comment.