Skip to content

Commit

Permalink
Fix highlighting of non-indented multi-line conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Dec 22, 2023
1 parent cbba24e commit 61effac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ syn match justExportedAssignment "\v^export%(\s|\\\n)+\h[a-zA-Z0-9_-]*\s*:\=" tr
syn match justExport '\v^export%(\s|\\\n)@=' contained

syn keyword justConditional if else
syn region justConditionalBraces start="\v\{@1<!\{\{@!" end="\v\}@=" transparent contains=@justExpr

syn match justLineLeadingSymbol "\v^%(\\\n)@3<!\s+\zs%(\@-|-\@|\@|-)"
syn match justLineContinuation "\\$" containedin=ALLBUT,justComment,justShebang,@justRawStrings,justBuiltInFunctionsError,justPreBodyCommentError
Expand Down Expand Up @@ -238,7 +239,7 @@ syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFuncInInterp,justRe

syn match justOperator "\v\=[=~]|!\=|[+/]"

syn cluster justExprBase contains=@justAllStrings,justConditional,justOperator
syn cluster justExprBase contains=@justAllStrings,justConditional,justConditionalBraces,justOperator
syn cluster justExpr contains=@justExprBase,@justBuiltInFunctions,justBuiltInFunctionArgs,justReplaceRegex

syn match justOldInclude "^!include\s.*$" contains=justOldIncludeDirective
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/tricky.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
, <span class="String">'_9</span><span class="Constant">${1}</span><span class="String">_'</span>
)

conditional_without_indent <span class="Operator">:=</span> <span class="Conditional">if</span> <span class="Function">env</span>(<span class="String">'SHELL'</span>) <span class="Operator">==</span> <span class="String">'/bin/bash'</span> {
valid_uuid <span class="Operator">+</span> testing
} <span class="Conditional">else</span> { <span class="String">''</span> }

<span class="Function">test</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Identifier">something</span><span class="Delimiter">}}{{</span><span class="Identifier">testing</span><span class="Delimiter">}}</span>

Expand Down
4 changes: 4 additions & 0 deletions tests/cases/tricky.just
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ not_a_uuid_anymore := replace_regex (
, '_9${1}_'
)

conditional_without_indent := if env('SHELL') == '/bin/bash' {
valid_uuid + testing
} else { '' }

test:
echo {{something}}{{testing}}

Expand Down

0 comments on commit 61effac

Please sign in to comment.