From 3166dc22563ad05e0aa7cc1a9b9d40c30e27aa1f Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Wed, 2 Aug 2023 16:50:49 -0400 Subject: [PATCH 01/13] Initial support for new line continuation syntax --- syntax/just.vim | 109 +++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index e60b8de..4bf7d9f 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -19,7 +19,7 @@ syn match justShebang "#!.*$" contains=justInterpolation syn match justName "\h[a-zA-Z0-9_-]*" contained syn match justFunction "\h[a-zA-Z0-9_-]*" contained -syn match justPreBodyComment "\v\s*#%([^!].*)?\n%(\t+| +)@=" transparent contained contains=justComment +syn match justPreBodyComment "\v%(\s|\\\n)*#%([^!].*)?\n%(\t+| +)@=" transparent contained contains=justComment \ nextgroup=@justBodies skipnl syn region justBacktick start=/`/ end=/`/ @@ -30,8 +30,8 @@ syn region justString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=justLineContin syn region justString start=/"""/ skip=/\\\\\|\\"/ end=/"""/ contains=justLineContinuation,justStringEscapeSequence syn cluster justAllStrings contains=justBacktick,justRawString,justString -syn match justRegexReplacement /\v,\_s*%('\_[^']*'|'''%(\_.%(''')@!)*\_.?''')\_s*\)/me=e-1 transparent contained contains=@justExpr,@justStringsWithRegexCapture -syn match justRegexReplacement /\v,\_s*%("%(\_[^"]|\\")*"|"""%(\_.%(""")@!)*\_.?""")\_s*\)/me=e-1 transparent contained contains=@justExpr,@justStringsWithRegexCapture +syn match justRegexReplacement /\v,%(\_s|\\\n)*%('\_[^']*'|'''%(\_.%(''')@!)*\_.?''')%(\_s|\\\n)*\)/me=e-1 transparent contained contains=@justExpr,@justStringsWithRegexCapture +syn match justRegexReplacement /\v,%(\_s|\\\n)*%("%(\_[^"]|\\")*"|"""%(\_.%(""")@!)*\_.?""")%(\_s|\\\n)*\)/me=e-1 transparent contained contains=@justExpr,@justStringsWithRegexCapture syn region justRawStrRegexRepl start=/\v'/ end=/'/ contained contains=justRegexCapture syn region justRawStrRegexRepl start=/\v'''/ end=/'''/ contained contains=justRegexCapture syn region justStringRegexRepl start=/\v"/ skip=/\\\\\|\\"/ end=/"/ contained contains=justLineContinuation,justStringEscapeSequence,justRegexCapture @@ -39,6 +39,8 @@ syn region justStringRegexRepl start=/\v"""/ skip=/\\\\\|\\"/ end=/"""/ containe syn match justRegexCapture '\v%(\$@1%(\s*\=)@!" contained - -syn match justRecipeAt "^@" contained -syn match justRecipeColon ":" contained - -syn match justRecipeAttr '^\v\[\s*%(no-%(cd|exit-message)|linux|macos|unix|windows|private)%(\s*,\s*%(no-%(cd|exit-message)|linux|macos|unix|windows|private))*\s*\]' - -syn match justRecipeDeclSimple "\v^\@?\h[a-zA-Z0-9_-]*%(\s*:\=@!)@=" - \ transparent contains=justRecipeName - \ nextgroup=justRecipeNoDeps,justRecipeDeps +syn match justVariadicPrefixError "\v\$%(\s|\\\n)*[*+]" contained -syn region justRecipeDeclComplex start="\v^\@?\h[a-zA-Z0-9_-]*\s+%([+*$]+\s*)*\h" end="\v%(:\=@!)@=|$" - \ transparent - \ contains=justRecipeName,justParameter - \ nextgroup=justRecipeNoDeps,justRecipeDeps - -syn match justRecipeName "\v^\@?\h[a-zA-Z0-9_-]*" transparent contained contains=justRecipeAt,justFunction +syn match justParameterError "\v%(%([+*$]+%(\s|\\\n)*)*\h[a-zA-Z0-9_-]*)@>%(%(\s|\\\n)*\=)@!" contained syn region justRecipeParenDefault - \ matchgroup=justRecipeDepParamsParen start='\v%(\=\s*)@<=\(' end='\V)' + \ 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|:#@=|:\s+#@=' +syn match justRecipeNoDeps '\v:%(\s|\\\n)*\n|:#@=|:\s+#@=' \ transparent contained \ contains=justRecipeColon \ nextgroup=justPreBodyComment,@justBodies -syn region justRecipeDeps start="\v:\s*%([a-zA-Z_(]|\&\&)" end="\v.#@=|\n" +syn region justRecipeDeps start="\v:%(\s|\\\n)*%([a-zA-Z_(]|\&\&)" skip='\\\n' end="\v.#@=|\\@1 Date: Wed, 2 Aug 2023 16:53:04 -0400 Subject: [PATCH 02/13] Add `env()` function --- justfile | 1 + syntax/just.vim | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index a0cd75c..88c65d6 100644 --- a/justfile +++ b/justfile @@ -73,6 +73,7 @@ functionsWithArgs := ''' absolute_path capitalize clean + env env_var env_var_or_default extension diff --git a/syntax/just.vim b/syntax/just.vim index 4bf7d9f..d7ef471 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -178,14 +178,14 @@ syn cluster justOtherCurlyBraces contains=justCurlyBraces,justBadCurlyBraces syn region justBuiltInFunctionWithArgs \ transparent end=')' - \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv_var%(_or_default)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" + \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" \ contains=justNoise,@justExpr syn region justBuiltInFuncWithArgsInInterp \ transparent end=')' - \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv_var%(_or_default)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" + \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" \ contained From 2afaf4f49929885eba219fa138ea5d6cea2414c8 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Wed, 2 Aug 2023 16:58:24 -0400 Subject: [PATCH 03/13] Add initial test case for line continuations --- tests/cases/line-continuations.html | 124 ++++++++++++++++++++++++++++ tests/cases/line-continuations.just | 124 ++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 tests/cases/line-continuations.html create mode 100644 tests/cases/line-continuations.just diff --git a/tests/cases/line-continuations.html b/tests/cases/line-continuations.html new file mode 100644 index 0000000..902fcc9 --- /dev/null +++ b/tests/cases/line-continuations.html @@ -0,0 +1,124 @@ +set \ +ignore-comments := true + +set \ + fallback \ + := \ + false + + +var \ + :=\ +'1' + '2' \ +\ + + '3' /\ +'456' + \ +if \ +'a' \ +!= \ +'b' \ +{\ + '\789'} \ +else\ +{ '\543'\ +\ +} + + +f1 := \ +uuid\ +\ +\ +(\ + + ) + +f2 := env (\ + + 'FOO_VAR', \ + +'0'\ + +) + +f3 := replace_regex \ +( \ + "FOOoo", + "([A-Z])[A-Z]+([^A-Z])", \ + "$1${2}" +\ +) + +test: a \ + b + echo '123' + +a: + echo 'A' +b: + echo 'B' +c: + echo 'C' + # ignored line + +test2 \ + param1="foo" param2 \ + = ''' +bar'''\ +param3 = \ + "b\ +a\ +z" \ +\ + * \ + $ \ + param4 \ += \ +f1 : + echo {{param1}} {{param2}} {{param3}} {{param4}} + +test3: \ + a b \ + c #comment \ + echo d + echo 'Test 3' + +test4 \ + +$PARAM='1': test \ + ( \ + test2 \ + 'bar' + + ) + env | grep -F PARAM + +test5: a \ + \ + \ + \ + b + echo 'Test5' + +test6: a\ +b + echo 'Test6' + +# the trailing space after the closing ] is intentional +[\ + no-cd \ + \ +, unix \ + ] +test7: + pwd + +alias\ +runpwd\ +:=\ +test7 + +test8 param1 \ += \ +( f1 + 'X' + f2) \ +: + echo {{param1}} diff --git a/tests/cases/line-continuations.just b/tests/cases/line-continuations.just new file mode 100644 index 0000000..167910a --- /dev/null +++ b/tests/cases/line-continuations.just @@ -0,0 +1,124 @@ +set \ +ignore-comments := true + +set \ + fallback \ + := \ + false + + +var \ + :=\ +'1' + '2' \ +\ + + '3' /\ +'456' + \ +if \ +'a' \ +!= \ +'b' \ +{\ + '\789'} \ +else\ +{ '\543'\ +\ +} + + +f1 := \ +uuid\ +\ +\ +(\ + + ) + +f2 := env (\ + + 'FOO_VAR', \ + +'0'\ + +) + +f3 := replace_regex \ +( \ + "FOOoo", + "([A-Z])[A-Z]+([^A-Z])", \ + "$1${2}" +\ +) + +test: a \ + b + echo '123' + +a: + echo 'A' +b: + echo 'B' +c: + echo 'C' + # ignored line + +test2 \ + param1="foo" param2 \ + = ''' +bar'''\ +param3 = \ + "b\ +a\ +z" \ +\ + * \ + $ \ + param4 \ += \ +f1 : + echo {{param1}} {{param2}} {{param3}} {{param4}} + +test3: \ + a b \ + c #comment \ + echo d + echo 'Test 3' + +test4 \ + +$PARAM='1': test \ + ( \ + test2 \ + 'bar' + + ) + env | grep -F PARAM + +test5: a \ + \ + \ + \ + b + echo 'Test5' + +test6: a\ +b + echo 'Test6' + +# the trailing space after the closing ] is intentional +[\ + no-cd \ + \ +, unix \ + ] +test7: + pwd + +alias\ +runpwd\ +:=\ +test7 + +test8 param1 \ += \ +( f1 + 'X' + f2) \ +: + echo {{param1}} From ecca6310ff905946b43039fcbf3a67f1f80aa6e2 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Wed, 2 Aug 2023 18:06:17 -0400 Subject: [PATCH 04/13] Initial support for line continuations in interpolations --- syntax/just.vim | 5 ++++- tests/cases/line-continuations.html | 9 ++++++++- tests/cases/line-continuations.just | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index d7ef471..e6f0df1 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -168,7 +168,10 @@ syn cluster justBodies contains=justBody,justShebangBody syn match justIndentError '\v^%(\\\n)@3.*)@<=\{\{\{@!" end="\v%(%(\\\n\z1|\S)\s*)@<=\}\}|$" + \ contained \ contains=justName,@justExprBase,@justBuiltInFunctionsInInterp syn match justBadCurlyBraces '\v\{{3}\ze[^{]' contained diff --git a/tests/cases/line-continuations.html b/tests/cases/line-continuations.html index 902fcc9..ec288f9 100644 --- a/tests/cases/line-continuations.html +++ b/tests/cases/line-continuations.html @@ -121,4 +121,11 @@ = \ ( f1 + 'X' + f2) \ : - echo {{param1}} + echo {{ \ + param1 \ + }} + +test9: + echo {{\ + uuid() \ + }} diff --git a/tests/cases/line-continuations.just b/tests/cases/line-continuations.just index 167910a..c31171e 100644 --- a/tests/cases/line-continuations.just +++ b/tests/cases/line-continuations.just @@ -121,4 +121,11 @@ test8 param1 \ = \ ( f1 + 'X' + f2) \ : - echo {{param1}} + echo {{ \ + param1 \ + }} + +test9: + echo {{\ + uuid() \ + }} From ce1b71f316798374a95a6a3b3cad9b0f9cc14bd5 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Thu, 3 Aug 2023 11:08:54 -0400 Subject: [PATCH 05/13] Add `num_cpus()` function --- justfile | 1 + syntax/just.vim | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 88c65d6..583492b 100644 --- a/justfile +++ b/justfile @@ -111,6 +111,7 @@ zeroArgFunctions := ''' just_executable justfile justfile_directory + num_cpus os os_family uuid diff --git a/syntax/just.vim b/syntax/just.vim index e6f0df1..fef3d00 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -194,7 +194,7 @@ syn region justBuiltInFuncWithArgsInInterp \ contained \ contains=justNoise,@justExprBase,@justBuiltInFunctionsInInterp,justName -syn match justBuiltInFunctionZeroArgs "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*\)" +syn match justBuiltInFunctionZeroArgs "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*\)" \ transparent contains=justFunction syn region justReplaceRegex @@ -207,7 +207,7 @@ syn region justReplaceRegexInInterp \ contained \ contains=justNoise,@justExprBase,justRegexReplacement,@justBuiltInFunctionsInInterp,justName -syn match justBuiltInFunctionsError "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%([^)[:space:]]%(\_s|\\\n)*)+\)" +syn match justBuiltInFunctionsError "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%([^)[:space:]]%(\_s|\\\n)*)+\)" syn cluster justBuiltInFunctions contains=justBuiltInFunctionZeroArgs,justBuiltInFunctionWithArgs,justReplaceRegex,justBuiltInFunctionsError syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFunctionZeroArgs,justBuiltInFuncWithArgsInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError From 0e36cf6d907d140b0b84d6185961c8c1c75e4798 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Thu, 3 Aug 2023 11:44:11 -0400 Subject: [PATCH 06/13] Improve justBuiltInFunctionsError matching --- justfile | 1 + syntax/just.vim | 13 +++++-------- tests/cases/invalid.html | 2 ++ tests/cases/invalid.just | 2 ++ tests/cases/line-continuations.html | 10 +++++----- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/justfile b/justfile index 583492b..594958a 100644 --- a/justfile +++ b/justfile @@ -116,6 +116,7 @@ zeroArgFunctions := ''' os_family uuid ''' +allFunctions := functionsWithArgs + zeroArgFunctions # generate an optimized Vim-style "very magic" regex snippet from a list of literal strings to match optrx +strings: diff --git a/syntax/just.vim b/syntax/just.vim index fef3d00..89da6a8 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -181,22 +181,19 @@ syn cluster justOtherCurlyBraces contains=justCurlyBraces,justBadCurlyBraces syn region justBuiltInFunctionWithArgs \ transparent end=')' - \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" + \ matchgroup=justFunction start="\v%(a%(bsolute_pat|rc)h|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|j%(oin|ust%(_executable|file%(_directory)?))|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|u%(pperca%(melca)?se|uid)|without_extension|invocation_directory%(_native)?|num_cpus|os%(_family)?)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" \ contains=justNoise,@justExpr syn region justBuiltInFuncWithArgsInInterp \ transparent end=')' - \ matchgroup=justFunction start="\v%(absolute_path|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|join|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|upperca%(melca)?se|without_extension)%(%(\s|\\\n)*\()@=" + \ matchgroup=justFunction start="\v%(a%(bsolute_pat|rc)h|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|j%(oin|ust%(_executable|file%(_directory)?))|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|u%(pperca%(melca)?se|uid)|without_extension|invocation_directory%(_native)?|num_cpus|os%(_family)?)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" \ contained \ contains=justNoise,@justExprBase,@justBuiltInFunctionsInInterp,justName -syn match justBuiltInFunctionZeroArgs "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*\)" - \ transparent contains=justFunction - syn region justReplaceRegex \ transparent end=')' \ matchgroup=justFunction start='\vreplace_regex%(%(\s|\\\n)*\()@=' @@ -207,10 +204,10 @@ syn region justReplaceRegexInInterp \ contained \ contains=justNoise,@justExprBase,justRegexReplacement,@justBuiltInFunctionsInInterp,justName -syn match justBuiltInFunctionsError "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%([^)[:space:]]%(\_s|\\\n)*)+\)" +syn match justBuiltInFunctionsError "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%(%([^)[:space:]\\]|\\\n@!)%(\_s|\\\n)*)+\)" -syn cluster justBuiltInFunctions contains=justBuiltInFunctionZeroArgs,justBuiltInFunctionWithArgs,justReplaceRegex,justBuiltInFunctionsError -syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFunctionZeroArgs,justBuiltInFuncWithArgsInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError +syn cluster justBuiltInFunctions contains=justBuiltInFunctionWithArgs,justReplaceRegex,justBuiltInFunctionsError +syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFuncWithArgsInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError syn match justOperator "\v\=[=~]|!\=|[+/]" diff --git a/tests/cases/invalid.html b/tests/cases/invalid.html index f1151fb..0103122 100644 --- a/tests/cases/invalid.html +++ b/tests/cases/invalid.html @@ -27,6 +27,8 @@ abc def ) +badfunc5 := num_cpus(\) + not_a_recipe_name #comment: not a recipe body diff --git a/tests/cases/invalid.just b/tests/cases/invalid.just index c861be3..2e65bc3 100644 --- a/tests/cases/invalid.just +++ b/tests/cases/invalid.just @@ -27,6 +27,8 @@ badfunc4 := justfile ( abc def ) +badfunc5 := num_cpus(\) + not_a_recipe_name #comment: not a recipe body diff --git a/tests/cases/line-continuations.html b/tests/cases/line-continuations.html index ec288f9..32d8106 100644 --- a/tests/cases/line-continuations.html +++ b/tests/cases/line-continuations.html @@ -26,12 +26,12 @@ f1 := \ -uuid\ -\ -\ -(\ +uuid\ +\ +\ +(\ - ) + ) f2 := env (\ From ba3efb92f2149050fe0ec10f202e4eaf05baa517 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Thu, 3 Aug 2023 13:59:48 -0400 Subject: [PATCH 07/13] Fix highlighting of parameter default values that are a bare built-in function --- syntax/just.vim | 28 ++++++++++++++++++++++++---- tests/cases/tricky.html | 6 ++++++ tests/cases/tricky.just | 6 ++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 89da6a8..47b9a20 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -82,6 +82,8 @@ syn region justParamValue contained transparent syn match justParamValue "\v%(\s|\\\n)*\=%(\s|\\\n)*\h[a-zA-Z0-9_-]*%(\s|\\\n)*" contained transparent \ contains=justParameterOperator \ nextgroup=justParameterError +syn match justParamValue "\v%(\s|\\\n)*\=%(\s|\\\n)*%(\w+%(\s|\\\n)*\()@=" contained transparent + \ contains=justParameterOperator nextgroup=@justBuiltInFunctionsParamValue syn match justParameterOperator "\V=" contained syn match justVariadicPrefix "\v%(\s|\\\n)@3<=[*+]%(%(\s|\\\n)*\$?%(\s|\\\n)*\h)@=" contained @@ -179,14 +181,23 @@ syn match justCurlyBraces '\v\{{4}' contained syn match justBadCurlyBraces '\v\{{5}\ze[^{]' contained syn cluster justOtherCurlyBraces contains=justCurlyBraces,justBadCurlyBraces -syn region justBuiltInFunctionWithArgs +syn region justBuiltInFunction \ transparent end=')' \ matchgroup=justFunction start="\v%(a%(bsolute_pat|rc)h|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|j%(oin|ust%(_executable|file%(_directory)?))|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|u%(pperca%(melca)?se|uid)|without_extension|invocation_directory%(_native)?|num_cpus|os%(_family)?)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" \ contains=justNoise,@justExpr -syn region justBuiltInFuncWithArgsInInterp +syn region justBuiltInFuncParamValue + \ transparent end='\v\)%(\s|\\\n)*' + \ matchgroup=justFunction start="\v%(a%(bsolute_pat|rc)h|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|j%(oin|ust%(_executable|file%(_directory)?))|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|u%(pperca%(melca)?se|uid)|without_extension|invocation_directory%(_native)?|num_cpus|os%(_family)?)%(%(\s|\\\n)*\()@=" + \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" + \ matchgroup=justBuiltInFunctionsError start="\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*\(" + \ contained + \ contains=justNoise,@justExpr + \ nextgroup=justParameterError + +syn region justBuiltInFuncInInterp \ transparent end=')' \ matchgroup=justFunction start="\v%(a%(bsolute_pat|rc)h|c%(apitalize|lean)|e%(nv%(_var%(_or_default)?)?|xtension)|file_%(name|stem)|j%(oin|ust%(_executable|file%(_directory)?))|kebabcase|lowerca%(melca)?se|pa%(rent_directory|th_exists)|quote|replace|s%(h%(a256%(_file)?|outy%(kebab|snake)case)|nakecase)|t%(itlecase|rim%(_%(end|start)%(_match%(es)?)?)?)|u%(pperca%(melca)?se|uid)|without_extension|invocation_directory%(_native)?|num_cpus|os%(_family)?)%(%(\s|\\\n)*\()@=" \ matchgroup=justUserDefinedError start="\verror%(%(\s|\\\n)*\()@=" @@ -198,6 +209,12 @@ syn region justReplaceRegex \ transparent end=')' \ matchgroup=justFunction start='\vreplace_regex%(%(\s|\\\n)*\()@=' \ contains=justNoise,@justExpr,justRegexReplacement +syn region justReplaceRegexParamValue + \ transparent end='\v\)%(\s|\\\n)*' + \ matchgroup=justFunction start='\vreplace_regex%(%(\s|\\\n)*\()@=' + \ contained + \ contains=justNoise,@justExpr,justRegexReplacement + \ nextgroup=justParameterError syn region justReplaceRegexInInterp \ transparent end=')' \ matchgroup=justFunction start='\vreplace_regex%(%(\s|\\\n)*\()@=' @@ -205,9 +222,12 @@ syn region justReplaceRegexInInterp \ contains=justNoise,@justExprBase,justRegexReplacement,@justBuiltInFunctionsInInterp,justName syn match justBuiltInFunctionsError "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%(%([^)[:space:]\\]|\\\n@!)%(\_s|\\\n)*)+\)" +syn match justBuiltInFuncErrorParamValue "\v%(arch|invocation_directory%(_native)?|just%(_executable|file%(_directory)?)|num_cpus|os%(_family)?|uuid)%(\s|\\\n)*\(%(\_s|\\\n)*%(%([^)[:space:]\\]|\\\n@!)%(\_s|\\\n)*)+\)%(\s|\\\n)*" + \ contained nextgroup=justParameterError -syn cluster justBuiltInFunctions contains=justBuiltInFunctionWithArgs,justReplaceRegex,justBuiltInFunctionsError -syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFuncWithArgsInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError +syn cluster justBuiltInFunctions contains=justBuiltInFunction,justReplaceRegex,justBuiltInFunctionsError +syn cluster justBuiltInFunctionsParamValue contains=justBuiltInFuncParamValue,justReplaceRegexParamValue,justBuiltInFuncErrorParamValue +syn cluster justBuiltInFunctionsInInterp contains=justBuiltInFuncInInterp,justReplaceRegexInInterp,justBuiltInFunctionsError syn match justOperator "\v\=[=~]|!\=|[+/]" diff --git a/tests/cases/tricky.html b/tests/cases/tricky.html index e6d3495..4f237bb 100644 --- a/tests/cases/tricky.html +++ b/tests/cases/tricky.html @@ -93,6 +93,12 @@ invoke shell: {{shell}} +multi count=num_cpus(): + seq -s ' ' 1 {{count}} + +functions2 cpus = num_cpus() foo = env('FOO', uuid()) : + echo '{{foo}}:x{{cpus}}' + env_test_export: env | grep -F -i export alias printenv:=env_test_export diff --git a/tests/cases/tricky.just b/tests/cases/tricky.just index 68a7457..411a7e2 100644 --- a/tests/cases/tricky.just +++ b/tests/cases/tricky.just @@ -93,6 +93,12 @@ spaced_paren_param2 param=(valid_uuid ) : invoke shell: {{shell}} +multi count=num_cpus(): + seq -s ' ' 1 {{count}} + +functions2 cpus = num_cpus() foo = env('FOO', uuid()) : + echo '{{foo}}:x{{cpus}}' + env_test_export: env | grep -F -i export alias printenv:=env_test_export From a01ae2bacb551063afacf85bcc1330dc072f5a85 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Thu, 3 Aug 2023 17:05:22 -0400 Subject: [PATCH 08/13] Improved line continuations support --- syntax/just.vim | 26 +++++++++++++---------- tests/cases/line-continuations.html | 33 ++++++++++++++++++++++++++++- tests/cases/line-continuations.just | 33 ++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 47b9a20..2289f11 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -21,6 +21,7 @@ syn match justFunction "\h[a-zA-Z0-9_-]*" contained syn match justPreBodyComment "\v%(\s|\\\n)*#%([^!].*)?\n%(\t+| +)@=" transparent contained contains=justComment \ nextgroup=@justBodies skipnl +syn match justPreBodyCommentError "\v^%(%(\\\n)@3runpwd\ :=\ test7 +foo \ +:= 'Foo!' test8 param1 \ = \ @@ -127,5 +129,34 @@ test9: echo {{\ - uuid() \ + num_cpus(\ + ) \ }} + +test10 param1=\ +num_cpus() \ + \ +param2\ +=\ +replace_regex(uuid(), +\ +'^(.+)$', "\"\\\"$1\\\"\"") param3= \ + env\ + ('BAR', + + + + \ + +replace('fghi', 'ghi', \ + 'foo') + +): \ +# comment \ + echo {{param1\ + / param2 }} + echo . + +test11: a \ +# comment\ + echo Test 11 diff --git a/tests/cases/line-continuations.just b/tests/cases/line-continuations.just index c31171e..2e82850 100644 --- a/tests/cases/line-continuations.just +++ b/tests/cases/line-continuations.just @@ -116,6 +116,8 @@ alias\ runpwd\ :=\ test7 +foo \ +:= 'Foo!' test8 param1 \ = \ @@ -127,5 +129,34 @@ test8 param1 \ test9: echo {{\ - uuid() \ + num_cpus(\ + ) \ }} + +test10 param1=\ +num_cpus() \ + \ +param2\ +=\ +replace_regex(uuid(), +\ +'^(.+)$', "\"\\\"$1\\\"\"") param3= \ + env\ + ('BAR', + + + + \ + +replace('fghi', 'ghi', \ + 'foo') + +): \ +# comment \ + echo {{param1\ + / param2 }} + echo . + +test11: a \ +# comment\ + echo Test 11 From fb7643c9d719e0955722a096074f9fc9bd70ce0d Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Thu, 3 Aug 2023 21:05:48 -0400 Subject: [PATCH 09/13] tests: Merge alias into recipes-simple --- tests/cases/alias.html | 4 ---- tests/cases/alias.just | 4 ---- tests/cases/recipes-simple.html | 5 +++++ tests/cases/recipes-simple.just | 5 +++++ 4 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 tests/cases/alias.html delete mode 100644 tests/cases/alias.just diff --git a/tests/cases/alias.html b/tests/cases/alias.html deleted file mode 100644 index eeb2ebd..0000000 --- a/tests/cases/alias.html +++ /dev/null @@ -1,4 +0,0 @@ -alias foo := bar - -alias: - foo diff --git a/tests/cases/alias.just b/tests/cases/alias.just deleted file mode 100644 index 341627c..0000000 --- a/tests/cases/alias.just +++ /dev/null @@ -1,4 +0,0 @@ -alias foo := bar - -alias: - foo diff --git a/tests/cases/recipes-simple.html b/tests/cases/recipes-simple.html index f276b75..38566b1 100644 --- a/tests/cases/recipes-simple.html +++ b/tests/cases/recipes-simple.html @@ -7,6 +7,11 @@ space-indent: echo foo foo-bar bar +alias foo := tab + +alias: + echo alias + simple_dep: dependency5 simple_multiline: diff --git a/tests/cases/recipes-simple.just b/tests/cases/recipes-simple.just index d832f9c..4ffe3e5 100644 --- a/tests/cases/recipes-simple.just +++ b/tests/cases/recipes-simple.just @@ -7,6 +7,11 @@ tab: space-indent: echo foo foo-bar bar +alias foo := tab + +alias: + echo alias + simple_dep: dependency5 simple_multiline: From 2073b83bc9ff57647ddfd7e49cb03c9867a3e387 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Sat, 5 Aug 2023 16:24:50 -0400 Subject: [PATCH 10/13] stricter matching recipe body indentation --- syntax/just.vim | 8 ++++---- tests/cases/invalid.html | 9 +++++++++ tests/cases/invalid.just | 9 +++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 2289f11..19227f4 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -155,14 +155,14 @@ syn match justLineLeadingSymbol "\v^%(\\\n)@3 echo 'valid again not valid' +bad_but_not_mixed_indentation: + echo 'tab indent' + echo 'space indent' +bad_but_not_mixed_indentation_shebang: + #!/bin/bash + echo 'space indent, same as first line' + echo 'acceptable space indent' + echo 'tab indent' + bad_curly_braces: echo {{{Odd number of opening curly braces is an error.}} echo {{{{{Odd number of opening curly braces is an error.}} diff --git a/tests/cases/invalid.just b/tests/cases/invalid.just index 2e65bc3..8c2595b 100644 --- a/tests/cases/invalid.just +++ b/tests/cases/invalid.just @@ -55,6 +55,15 @@ invalid_recipe_body4: echo 'valid again not valid' +bad_but_not_mixed_indentation: + echo 'tab indent' + echo 'space indent' +bad_but_not_mixed_indentation_shebang: + #!/bin/bash + echo 'space indent, same as first line' + echo 'acceptable space indent' + echo 'tab indent' + bad_curly_braces: echo {{{Odd number of opening curly braces is an error.}} echo {{{{{Odd number of opening curly braces is an error.}} From c09de30540c747da21f5f9e8bc6c281bdeb378e3 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Sat, 5 Aug 2023 16:32:06 -0400 Subject: [PATCH 11/13] add couple more line continuation test cases --- tests/cases/line-continuations.html | 8 ++++++++ tests/cases/line-continuations.just | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/cases/line-continuations.html b/tests/cases/line-continuations.html index c2418e2..b806e93 100644 --- a/tests/cases/line-continuations.html +++ b/tests/cases/line-continuations.html @@ -160,3 +160,11 @@ test11: a \ # comment\ echo Test 11 + +test12: \ + + echo Test 12 + +test13: a\ + + echo Test13 diff --git a/tests/cases/line-continuations.just b/tests/cases/line-continuations.just index 2e82850..a21ba2a 100644 --- a/tests/cases/line-continuations.just +++ b/tests/cases/line-continuations.just @@ -160,3 +160,11 @@ replace('fghi', 'ghi', \ test11: a \ # comment\ echo Test 11 + +test12: \ + + echo Test 12 + +test13: a\ + + echo Test13 From 9f4f126a8e692f9a7f81534c820599cd4709254c Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Sat, 5 Aug 2023 16:38:21 -0400 Subject: [PATCH 12/13] Simplify justBody start expression --- syntax/just.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/just.vim b/syntax/just.vim index 19227f4..eccfaa6 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -155,7 +155,7 @@ syn match justLineLeadingSymbol "\v^%(\\\n)@3 Date: Fri, 6 Oct 2023 12:03:38 -0400 Subject: [PATCH 13/13] Update `Last Change` dates --- ftplugin/just.vim | 2 +- syntax/just.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ftplugin/just.vim b/ftplugin/just.vim index db2dae0..5000006 100644 --- a/ftplugin/just.vim +++ b/ftplugin/just.vim @@ -2,7 +2,7 @@ " Language: Justfile " Maintainer: Noah Bogart " URL: https://github.com/NoahTheDuke/vim-just.git -" Last Change: 2023 Mar 26 +" Last Change: 2023 Jul 08 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") diff --git a/syntax/just.vim b/syntax/just.vim index eccfaa6..66cd6b4 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -2,7 +2,7 @@ " Language: Justfile " Maintainer: Noah Bogart " URL: https://github.com/NoahTheDuke/vim-just.git -" Last Change: 2023 Apr 12 +" Last Change: 2023 Aug 05 if exists('b:current_syntax') finish