Skip to content

Commit

Permalink
Relax assignment matching to not unnecessarily require spaces surroun…
Browse files Browse the repository at this point in the history
…ding the assignment operator
  • Loading branch information
laniakea64 committed Jul 31, 2023
1 parent 9129b09 commit fab5ea0
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
28 changes: 14 additions & 14 deletions syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,36 @@ syn match justRecipeDepParamsParen '\v\(\s*[a-zA-Z_][a-zA-Z0-9_-]*' contained co

syn keyword justBoolean true false contained

syn match justAssignment "\v^[a-zA-Z_][a-zA-Z0-9_-]*\s+:\=" transparent contains=justAssignmentOperator
syn match justAssignment "\v^[a-zA-Z_][a-zA-Z0-9_-]*\s*:\=" transparent contains=justAssignmentOperator

syn match justSet '\v^set\ze\s+' contained
syn match justSet '\v^set\s@=' contained
syn match justSetKeywords "\v%(allow-duplicate-recipes|dotenv-load|export|fallback|ignore-comments|positional-arguments|tempdir|shell|windows-shell)" contained
syn match justSetDeprecatedKeywords 'windows-powershell' contained
syn match justBooleanSet "\v^set\s+%(allow-duplicate-recipes|dotenv-load|export|fallback|ignore-comments|positional-arguments|windows-powershell)%(\s+:\=\s+%(true|false))?$"
syn match justBooleanSet "\v^set\s+%(allow-duplicate-recipes|dotenv-load|export|fallback|ignore-comments|positional-arguments|windows-powershell)%(\s*:\=\s*%(true|false))?$"
\ contains=justSet,justSetKeywords,justSetDeprecatedKeywords,justAssignmentOperator,justBoolean
\ transparent

syn match justStringSet '\v^set\s+%(tempdir)\s+:\=\s+%(['"])@=' transparent contains=justSet,justSetKeywords,justAssignmentOperator
syn match justStringSet '\v^set\s+%(tempdir)\s*:\=\s*%(['"])@=' transparent contains=justSet,justSetKeywords,justAssignmentOperator

syn region justShellSet
\ start=/\v^set\s+%(windows-)?shell\s+:\=\s+\[/
\ start=/\v^set\s+%(windows-)?shell\s*:\=\s*\[/
\ end="]"
\ contains=justSet,justSetKeywords,justAssignmentOperator,justString,justRawString,justNoise,justSetError
\ transparent skipwhite

syn match justSetError '\v%(%(\[|,)%(\s|\n)*)@<=[^'"\][:space:]][^,\][:space:]]*|\[%(\s|\n)*\]' contained

syn region justAlias
\ matchgroup=justAlias start="\v^alias\ze\s+[a-zA-Z_][a-zA-Z0-9_-]*\s+:\="
\ end="$"
\ contains=justFunction,justAssignmentOperator
\ oneline skipwhite
syn match justAlias '\v^alias\s@=' contained
syn match justAliasDecl "\v^alias\s+[a-zA-Z_][a-zA-Z0-9_-]*\s*:\=\s*"
\ transparent
\ contains=justAlias,justFunction,justAssignmentOperator
\ nextgroup=justAliasRes
syn match justAliasRes '\v[a-zA-Z_][a-zA-Z0-9_-]*\s*%(#@=|$)' contained transparent contains=justFunction

syn match justExportedAssignment "\v^export\s+[a-zA-Z_][a-zA-Z0-9_-]*\s+:\="
\ contains=justExport,justAssignmentOperator,@justExpr
\ transparent oneline skipwhite
syn match justExportedAssignment "\v^export\s+[a-zA-Z_][a-zA-Z0-9_-]*\s*:\=" transparent
\ contains=justExport,justAssignmentOperator

syn match justExport '\v^export\ze\s+' contained
syn match justExport '\v^export\s@=' contained

syn keyword justConditional if else

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/alias.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span class="Statement">alias </span><span class="Function">foo</span><span class="Statement"> </span><span class="Operator">:=</span><span class="Statement"> </span><span class="Function">bar</span>
<span class="Statement">alias</span> <span class="Function">foo</span> <span class="Operator">:=</span> <span class="Function">bar</span>

<span class="Function">alias</span><span class="Operator">:</span>
<span class="Number"> foo</span>
2 changes: 1 addition & 1 deletion tests/cases/kitchen-sink.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span class="Statement">set</span> <span class="Keyword">dotenv-load</span>
<span class="Statement">set</span> <span class="Keyword">export</span>

<span class="Statement">alias </span><span class="Function">s</span><span class="Statement"> </span><span class="Operator">:=</span><span class="Statement"> </span><span class="Function">serve</span>
<span class="Statement">alias</span> <span class="Function">s</span> <span class="Operator">:=</span> <span class="Function">serve</span>

bt <span class="Operator">:=</span> <span class="String">'0'</span>

Expand Down
13 changes: 13 additions & 0 deletions tests/cases/set.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@
, <span class="String">'''</span>
<span class="String">prefix'''</span>
]
<span class="Statement">set</span> <span class="Keyword">shell</span><span class="Operator">:=</span>[<span class="String">'bash'</span>,<span class="String">"-c"</span>]

<span class="Statement">set</span> <span class="Keyword">windows-shell</span><span class="Operator">:=</span>[<span class="String">"powershell.exe"</span>, <span class="String">"-NoLogo"</span>, <span class="String">"-Command"</span>]

<span class="Statement">set</span> <span class="Underlined">windows-powershell</span>
<span class="Statement">set</span> <span class="Underlined">windows-powershell</span><span class="Operator">:=</span><span class="Boolean">false</span>
<span class="Statement">set</span> <span class="Underlined">windows-powershell</span> <span class="Operator">:=</span> <span class="Boolean">true</span>

<span class="Statement">set</span> <span class="Keyword">fallback</span>
<span class="Statement">set</span> <span class="Keyword">fallback</span> <span class="Operator">:=</span> <span class="Boolean">true</span>
<span class="Statement">set</span> <span class="Keyword">fallback</span> <span class="Operator">:=</span> <span class="Boolean">false</span>
<span class="Statement">set</span> <span class="Keyword">fallback</span><span class="Operator">:=</span><span class="Boolean">false</span>
<span class="Statement">set</span> <span class="Keyword">fallback</span><span class="Operator">:=</span> <span class="Boolean">true</span>
<span class="Statement">set</span> <span class="Keyword">fallback</span> <span class="Operator">:=</span><span class="Boolean">false</span>

<span class="Statement">set</span> <span class="Keyword">tempdir</span> <span class="Operator">:=</span> <span class="String">'/tmp'</span>
<span class="Statement">set</span> <span class="Keyword">tempdir</span> <span class="Operator">:=</span> <span class="String">"""</span>
<span class="String">/tmp"""</span>
<span class="Statement">set</span> <span class="Keyword">tempdir</span><span class="Operator">:=</span><span class="String">"/tmp"</span>
<span class="Statement">set</span> <span class="Keyword">tempdir</span><span class="Operator">:=</span> <span class="String">"/tmp"</span>
<span class="Statement">set</span> <span class="Keyword">tempdir</span> <span class="Operator">:=</span><span class="String">'/tmp'</span>
13 changes: 13 additions & 0 deletions tests/cases/set.just
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@ import sys\nprint(sys.argv[1:])
, '''
prefix'''
]
set shell:=['bash',"-c"]

set windows-shell:=["powershell.exe", "-NoLogo", "-Command"]

set windows-powershell
set windows-powershell:=false
set windows-powershell := true

set fallback
set fallback := true
set fallback := false
set fallback:=false
set fallback:= true
set fallback :=false

set tempdir := '/tmp'
set tempdir := """
/tmp"""
set tempdir:="/tmp"
set tempdir:= "/tmp"
set tempdir :='/tmp'
6 changes: 5 additions & 1 deletion tests/cases/tricky.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
<span class="Special"> foo=`echo ' testing '`;echo $foo 123</span>
<span class="Special">```</span>

nospace<span class="Operator">:=</span><span class="String">'ABCabc'</span>

other_export <span class="Operator">:=</span> <span class="String">'1'</span>
<span class="Statement">export</span> some_export <span class="Operator">:=</span> <span class="String">'0'</span> <span class="Operator">+</span> other_export
<span class="Statement">export</span> SOME_EXPORT2<span class="Operator">:=</span><span class="String">'1'</span>

valid_uuid <span class="Operator">:=</span> <span class="Function">uuid</span>( )

Expand Down Expand Up @@ -88,4 +91,5 @@
<span class="Number"> </span><span class="Delimiter">{{</span><span class="Identifier">shell</span><span class="Delimiter">}}</span>

<span class="Function">env_test_export</span><span class="Operator">:</span>
<span class="Number"> env | grep -F export</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>
6 changes: 5 additions & 1 deletion tests/cases/tricky.just
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ testing := ```
foo=`echo ' testing '`;echo $foo 123
```

nospace:='ABCabc'

other_export := '1'
export some_export := '0' + other_export
export SOME_EXPORT2:='1'

valid_uuid := uuid( )

Expand Down Expand Up @@ -88,4 +91,5 @@ invoke shell:
{{shell}}
env_test_export:
env | grep -F export
env | grep -F -i export
alias printenv:=env_test_export

0 comments on commit fab5ea0

Please sign in to comment.