Skip to content

Commit

Permalink
Support [attribute: value] syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Jun 14, 2024
1 parent bbe53e9 commit 72ce005
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ syn match justRecipeColon ":" contained

syn region justRecipeAttributes
\ matchgroup=justRecipeAttr start='\v^%(\\\n)@3<!\[' end='\V]'
\ contains=justRecipeAttr,justRecipeAttrSep,justRecipeAttrArgs,justRecipeAttrArgError
\ contains=justRecipeAttr,justRecipeAttrSep,justRecipeAttrArgs,justRecipeAttrArgError,justRecipeAttrValueShort

syn keyword justRecipeAttr
\ confirm doc group linux macos no-cd no-exit-message no-quiet positional-arguments private unix windows
\ contained
syn match justRecipeAttrSep ',' contained
syn match justRecipeAttrValueShort '\v:%(\_s|\\\n)*' transparent contained
\ contains=justRecipeAttrValueColon nextgroup=@justStringLiterals
syn match justRecipeAttrValueColon '\V:' contained
syn region justRecipeAttrArgs matchgroup=justRecipeAttr start='\V(' end='\V)' contained
\ contains=@justStringLiterals
syn match justRecipeAttrArgError '\v\(%(\s|\\?\n)*\)' contained
Expand Down Expand Up @@ -338,6 +341,7 @@ hi def link justRecipeAt Special
hi def link justRecipeAttr Type
hi def link justRecipeAttrArgError Error
hi def link justRecipeAttrSep Operator
hi def link justRecipeAttrValueColon Operator
hi def link justRecipeColon Operator
hi def link justRecipeDepParamsParen Delimiter
hi def link justRecipeSubsequentDeps Operator
Expand Down
19 changes: 19 additions & 0 deletions tests/cases/recipes-with-extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,22 @@
<span class="Type">[positional-arguments]</span>
<span class="Function">positional</span> <span class="Statement">*</span><span class="Identifier">args</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">"$@"</span>

<span class="Type">[group</span><span class="Operator">:</span> <span class="String">'foo group'</span><span class="Type">]</span>
<span class="Function">attr-colon1</span><span class="Operator">:</span>
<span class="Number"> echo foo</span>

<span class="Type">[group</span> <span class="Operator">:</span> <span class="Special">\</span>
<span class="Special">\</span>
<span class="String">"foo group"</span>
<span class="Type">]</span>
<span class="Function">attr-colon2</span><span class="Operator">:</span>
<span class="Number"> echo foo</span>

<span class="Type">[</span>
<span class="Type">doc</span><span class="Operator">:</span>
<span class="String">"Documentation"</span><span class="Operator">,</span>

<span class="Type">group</span><span class="Operator">:</span><span class="String">'foo group'</span> <span class="Type">]</span>
<span class="Function">attr-colon3</span><span class="Operator">:</span>
<span class="Number"> echo foo</span>
19 changes: 19 additions & 0 deletions tests/cases/recipes-with-extras.just
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,22 @@ long_doc:
[positional-arguments]
positional *args:
echo "$@"

[group: 'foo group']
attr-colon1:
echo foo

[group : \
\
"foo group"
]
attr-colon2:
echo foo

[
doc:
"Documentation",

group:'foo group' ]
attr-colon3:
echo foo

0 comments on commit 72ce005

Please sign in to comment.