Skip to content

Commit

Permalink
Improve highlighting of recipe attributes:
Browse files Browse the repository at this point in the history
 - Highlight separating commas differently from recipe attribute names
 - Fix highlighting of valid multi-line recipe attribute constructs without line continuations
  • Loading branch information
laniakea64 committed Dec 26, 2023
1 parent f3c0eb1 commit 4125820
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
10 changes: 9 additions & 1 deletion syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ syn region justExprParenInInterp start='\V(' end='\V)' transparent contained con
syn match justRecipeAt "^@" contained
syn match justRecipeColon ":" contained

syn match justRecipeAttr '^\v\[%(\s|\\\n)*%(confirm|no-%(cd|exit-message)|linux|macos|unix|windows|private)%(%(\s|\\\n)*,%(\s|\\\n)*%(confirm|no-%(cd|exit-message)|linux|macos|unix|windows|private))*%(\s|\\\n)*\]'
syn region justRecipeAttributes
\ matchgroup=justRecipeAttr start='\v^%(\\\n)@3<!\[' end='\V]'
\ contains=justRecipeAttr,justRecipeAttrSep

syn keyword justRecipeAttr
\ confirm linux macos no-cd no-exit-message private unix windows
\ contained
syn match justRecipeAttrSep ',' contained

syn match justRecipeDeclSimple "\v^\@?\h\k*%(%(\s|\\\n)*:\=@!)@="
\ transparent contains=justRecipeName
Expand Down Expand Up @@ -267,6 +274,7 @@ hi def link justRawString String
hi def link justRawStrRegexRepl String
hi def link justRecipeAt Special
hi def link justRecipeAttr Type
hi def link justRecipeAttrSep Operator
hi def link justRecipeColon Operator
hi def link justRecipeDepParamsParen Delimiter
hi def link justRecipeSubsequentDeps Operator
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/line-continuations.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@

<span class="Comment"># the trailing space after the closing ] is intentional</span>
<span class="Type">[</span><span class="Special">\</span>
<span class="Type"> no-cd </span><span class="Special">\</span>
<span class="Type"> </span><span class="Special">\</span>
<span class="Type">, unix </span><span class="Special">\</span>
<span class="Type"> ]</span>
<span class="Type">no-cd</span> <span class="Special">\</span>
<span class="Special">\</span>
<span class="Operator">,</span> <span class="Type">unix</span> <span class="Special">\</span>
<span class="Type">]</span>
<span class="Function">test7</span><span class="Operator">:</span>
<span class="Number"> pwd</span>

Expand Down
17 changes: 13 additions & 4 deletions tests/cases/recipes-with-extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,27 @@
<span class="Function">error</span><span class="Operator">:</span>
<span class="Number"> sh -c </span><span class="String">'echo Exit 3;exit 3'</span>

<span class="Type">[ unix ]</span>
<span class="Type">[ macos,windows, linux ]</span>
<span class="Type">[</span> <span class="Type">unix</span> <span class="Type">]</span>
<span class="Type">[</span> <span class="Type">macos</span><span class="Operator">,</span><span class="Type">windows</span><span class="Operator">,</span> <span class="Type">linux</span> <span class="Type">]</span>
<span class="Function">any</span><span class="Operator">:</span>
<span class="Number"> echo foo</span>

<span class="Type">[ private ,no-cd , unix]</span>
<span class="Type">[no-exit-message ]</span>
<span class="Type">[</span> <span class="Type">private</span> <span class="Operator">,</span><span class="Type">no-cd</span> <span class="Operator">,</span> <span class="Type">unix]</span>
<span class="Type">[no-exit-message</span> <span class="Type">]</span>
<span class="Function">runpwd_then_error</span><span class="Operator">:</span>
<span class="Number"> pwd</span>
<span class="Number"> sh -c </span><span class="String">'exit 2'</span>
<span class="Number"> echo unreachable</span>

<span class="Type">[</span>
<span class="Type">private</span>
<span class="Operator">,</span>

<span class="Type">confirm</span>
<span class="Type">]</span>
<span class="Function">multiline-attr-no-continuations</span><span class="Operator">:</span>
<span class="Number"> /bin/true</span>

somevar <span class="Operator">:=</span> <span class="String">"1"</span>
<span class="Function">interp_with_func_with_arg</span> <span class="Identifier">foo</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Normal">)</span><span class="Delimiter">}}</span>
Expand Down
9 changes: 9 additions & 0 deletions tests/cases/recipes-with-extras.just
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ runpwd_then_error:
sh -c 'exit 2'
echo unreachable

[
private
,

confirm
]
multiline-attr-no-continuations:
/bin/true

somevar := "1"
interp_with_func_with_arg foo:
echo {{quote(foo)}}
Expand Down

0 comments on commit 4125820

Please sign in to comment.