Skip to content

Commit

Permalink
Add is_dependency() function and [positional-arguments] attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Jun 14, 2024
1 parent 721131f commit bbe53e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ syn region justRecipeAttributes
\ contains=justRecipeAttr,justRecipeAttrSep,justRecipeAttrArgs,justRecipeAttrArgError

syn keyword justRecipeAttr
\ confirm doc group linux macos no-cd no-exit-message no-quiet private unix windows
\ confirm doc group linux macos no-cd no-exit-message no-quiet positional-arguments private unix windows
\ contained
syn match justRecipeAttrSep ',' contained
syn region justRecipeAttrArgs matchgroup=justRecipeAttr start='\V(' end='\V)' contained
Expand Down Expand Up @@ -229,7 +229,7 @@ syn match justFunctionCall "\v\w+%(\s|\\\n)*\(@=" transparent contains=justBuilt

" error() is intentionally not included in this list
syn keyword justBuiltInFunction
\ absolute_path append arch blake3 blake3_file cache_directory canonicalize capitalize choose clean config_directory config_local_directory data_directory data_local_directory encode_uri_component env env_var env_var_or_default executable_directory extension file_name file_stem home_directory invocation_directory invocation_directory_native join just_executable justfile justfile_directory just_pid kebabcase lowercamelcase lowercase module_directory module_file num_cpus os os_family parent_directory path_exists prepend quote replace replace_regex semver_matches sha256 sha256_file shell shoutykebabcase shoutysnakecase snakecase source_directory source_file titlecase trim trim_end trim_end_match trim_end_matches trim_start trim_start_match trim_start_matches uppercamelcase uppercase uuid without_extension
\ absolute_path append arch blake3 blake3_file cache_directory canonicalize capitalize choose clean config_directory config_local_directory data_directory data_local_directory encode_uri_component env env_var env_var_or_default executable_directory extension file_name file_stem home_directory invocation_directory invocation_directory_native is_dependency join just_executable justfile justfile_directory just_pid kebabcase lowercamelcase lowercase module_directory module_file num_cpus os os_family parent_directory path_exists prepend quote replace replace_regex semver_matches sha256 sha256_file shell shoutykebabcase shoutysnakecase snakecase source_directory source_file titlecase trim trim_end trim_end_match trim_end_matches trim_start trim_start_match trim_start_matches uppercamelcase uppercase uuid without_extension
\ contained

syn match justUserDefinedError "\v%(assert|error)%(%(\s|\\\n)*\()@="
Expand Down
9 changes: 9 additions & 0 deletions tests/cases/recipes-with-extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<span class="Function">dependency3</span> <span class="Identifier">theparam</span><span class="Operator">=</span><span class="Delimiter">(</span><span class="String">'a'</span> <span class="Operator">+</span> (<span class="Conditional">if</span> <span class="Function">env_var_or_default</span>(<span class="String">'FOO'</span>, <span class="Function">blake3_file</span>(<span class="Function">justfile</span>())) <span class="Operator">==</span> <span class="String">'1'</span> { <span class="String">' With Foo'</span>} <span class="Conditional">else</span> { <span class="String">' none '</span> <span class="Operator">+</span> p1 <span class="Operator">/</span> p2 }) <span class="Operator">/</span> <span class="String">'b'</span><span class="Delimiter">)</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">theparam</span><span class="Normal">)</span><span class="Delimiter">}}</span>

<span class="Function">dependency4</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'Is Dependency:'</span><span class="Number"> </span><span class="Delimiter">{{</span><span class="Function">is_dependency</span><span class="Normal">()</span><span class="Delimiter">}}</span>

<span class="Function">test_dependency4</span><span class="Operator">:</span> <span class="Function">dependency4</span>

<span class="Function">test4</span><span class="Operator">:</span> <span class="Delimiter">(</span><span class="Function">dependency2</span> <span class="String">"123"</span>
<span class="Operator">+</span> <span class="String">'456'</span><span class="Delimiter">)</span>
<span class="Number"> echo Test</span>
Expand Down Expand Up @@ -124,3 +129,7 @@
<span class="String">'''</span><span class="Type">)]</span>
<span class="Function">long_doc</span><span class="Operator">:</span>
<span class="Number"> echo foo foo</span>

<span class="Type">[positional-arguments]</span>
<span class="Function">positional</span> <span class="Statement">*</span><span class="Identifier">args</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">"$@"</span>
9 changes: 9 additions & 0 deletions tests/cases/recipes-with-extras.just
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ dependency2 firstparam=("abc\t" / 'def\t\"') secondparam=("""
dependency3 theparam=('a' + (if env_var_or_default('FOO', blake3_file(justfile())) == '1' { ' With Foo'} else { ' none ' + p1 / p2 }) / 'b'):
echo {{quote(theparam)}}

dependency4:
echo 'Is Dependency:' {{is_dependency()}}

test_dependency4: dependency4

test4: (dependency2 "123"
+ '456')
echo Test
Expand Down Expand Up @@ -124,3 +129,7 @@ not_documented:
''')]
long_doc:
echo foo foo

[positional-arguments]
positional *args:
echo "$@"

0 comments on commit bbe53e9

Please sign in to comment.