Skip to content

Commit

Permalink
Fix highlighting where a parenthesized recipe dependency contains a p…
Browse files Browse the repository at this point in the history
…arenthesized parameter
  • Loading branch information
laniakea64 committed Nov 14, 2023
1 parent 743cbe2 commit 8fa4691
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
14 changes: 9 additions & 5 deletions syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ syn region justRecipeParenDefault
\ matchgroup=justRecipeDepParamsParen start='\v%(\=%(\s|\\\n)*)@<=\(' end='\V)'
\ contained
\ contains=@justExpr,justParenInner
syn region justParenInner start='\V(' end='\V)' contained contains=justParenInner,@justExpr

syn match justRecipeSubsequentDeps '&&' contained

syn match justRecipeNoDeps '\v:%(\s|\\\n)*\n|:#@=|:%(\s|\\\n)+#@='
Expand All @@ -111,10 +109,12 @@ syn region justRecipeDeps start="\v:%(\s|\\\n)*%([a-zA-Z_(]|\&\&)" skip='\\\n' e
\ nextgroup=justPreBodyComment,justPreBodyCommentError,@justBodies

syn region justRecipeParamDep contained transparent
\ matchgroup=justRecipeDepParamsParen
\ start="("
\ matchgroup=justRecipeDepParamsParen end=")"
\ contains=justRecipeDepParamsParen,@justExpr
syn match justRecipeDepParamsParen '\v\(%(\s|\\\n)*\h[a-zA-Z0-9_-]*' contained contains=justFunction
\ end=")"
\ contains=justRecipeDepParenName,justParenInner,@justExpr

syn region justParenInner start='\V(' end='\V)' contained contains=justParenInner,@justExpr

syn keyword justBoolean true false contained

Expand Down Expand Up @@ -228,6 +228,10 @@ syn match justBuiltInFuncErrorParamValue "\v%(arch|invocation_directory%(_native

syn match justParameterLineContinuation '\v%(\s|\\\n)*' contained nextgroup=justParameterError

syn match justRecipeDepParenName '\v%(\(%(\s|\\\n)*)@<=\h[a-zA-Z0-9_-]*'
\ transparent contained
\ contains=justFunction

syn cluster justBuiltInFunctions contains=justBuiltInFunction,justReplaceRegex,justBuiltInFunctionsError
syn cluster justBuiltInFunctionsParamValue contains=justBuiltInFuncParamValue,justReplaceRegexParamValue,justBuiltInFuncErrorParamValue
syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFuncInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/line-continuations.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@

<span class="Function">test4</span> <span class="Special">\</span>
<span class="Statement">+</span><span class="Statement">$</span><span class="Identifier">PARAM</span><span class="Operator">=</span><span class="String">'1'</span><span class="Operator">:</span> <span class="Function">test</span> <span class="Special">\</span>
<span class="Delimiter">( </span><span class="Special">\</span>
<span class="Delimiter"> </span><span class="Function">test2</span> <span class="Special">\</span>
<span class="Delimiter">(</span> <span class="Special">\</span>
<span class="Function">test2</span> <span class="Special">\</span>
<span class="String">'bar'</span>

<span class="Delimiter">)</span>
Expand Down
10 changes: 10 additions & 0 deletions tests/cases/tricky.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@
<span class="Function">env_test_export</span><span class="Operator">:</span>
<span class="Number"> env | grep -F -i export</span>
<span class="Statement">alias</span> <span class="Function">printenv</span><span class="Operator">:=</span><span class="Function">env_test_export</span>

<span class="Function">parenthesized_dep_param</span><span class="Operator">:</span> <span class="Delimiter">(</span><span class="Function">multi</span> (<span class="String">'1'</span> <span class="Operator">+</span> <span class="String">'0'</span>)<span class="Delimiter">)</span>

<span class="Function">parenthesized_dep_param2</span> <span class="Identifier">p</span><span class="Operator">:</span> <span class="Delimiter">(</span><span class="Function">invoke</span> <span class="Special">\</span>
(p <span class="Operator">+</span> <span class="String">" -c 'echo 123'"</span>) <span class="Special">\</span>
<span class="Delimiter">)</span>

<span class="Function">parenthesized_dep_param3</span><span class="Operator">:</span> <span class="Delimiter">(</span><span class="Function">multi</span> <span class="Special">\</span>
( <span class="String">'1'</span> <span class="Operator">+</span> <span class="String">'0'</span> ) <span class="Special">\</span>
<span class="Delimiter">)</span>
10 changes: 10 additions & 0 deletions tests/cases/tricky.just
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@ functions2 cpus = num_cpus() foo = env('FOO', uuid()) :
env_test_export:
env | grep -F -i export
alias printenv:=env_test_export
parenthesized_dep_param: (multi ('1' + '0'))
parenthesized_dep_param2 p: (invoke \
(p + " -c 'echo 123'") \
)
parenthesized_dep_param3: (multi \
( '1' + '0' ) \
)

0 comments on commit 8fa4691

Please sign in to comment.