Skip to content

Commit

Permalink
Highlight replace_regex replacement capture substitutions as `Ident…
Browse files Browse the repository at this point in the history
…ifier`

This is more semantically correct based on `:help group-name`, and now that `just` has actual constants it doesn't make sense to highlight these as `Constant`.
  • Loading branch information
laniakea64 committed May 20, 2024
1 parent ff78bc7 commit 88d81ff
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ hi def link justRecipeAttrSep Operator
hi def link justRecipeColon Operator
hi def link justRecipeDepParamsParen Delimiter
hi def link justRecipeSubsequentDeps Operator
hi def link justRegexCapture Constant
hi def link justRegexCapture Identifier
hi def link justSet Statement
hi def link justSetDeprecatedKeywords Underlined
hi def link justSetKeywords Keyword
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 @@ -45,7 +45,7 @@
( <span class="Special">\</span>
<span class="String">"FOOoo"</span>,
<span class="String">"([A-Z])[A-Z]+([^A-Z])"</span>, <span class="Special">\</span>
<span class="String">"</span><span class="Constant">$1${2}</span><span class="String">"</span>
<span class="String">"</span><span class="Identifier">$1${2}</span><span class="String">"</span>
<span class="Special">\</span>
)

Expand Down Expand Up @@ -140,7 +140,7 @@
<span class="Operator">=</span><span class="Special">\</span>
<span class="Function">replace_regex</span>(<span class="Function">uuid</span>(),
<span class="Special">\</span>
<span class="String">'^(.+)$'</span>, <span class="String">"</span><span class="Special">\"\\\"</span><span class="Constant">$1</span><span class="Special">\\\"\"</span><span class="String">"</span>) <span class="Identifier">param3</span><span class="Operator">=</span> <span class="Special">\</span>
<span class="String">'^(.+)$'</span>, <span class="String">"</span><span class="Special">\"\\\"</span><span class="Identifier">$1</span><span class="Special">\\\"\"</span><span class="String">"</span>) <span class="Identifier">param3</span><span class="Operator">=</span> <span class="Special">\</span>
<span class="Function">env</span><span class="Special">\</span>
(<span class="String">'BAR'</span>,

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/recipes-with-extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

p1 <span class="Operator">:=</span> <span class="String">'test'</span>
p2 <span class="Operator">:=</span> <span class="Function">canonicalize</span>(<span class="String">'..'</span>)
pdirname <span class="Operator">:=</span> <span class="Function">replace_regex</span>(p2, <span class="String">'/([^/]*)$'</span>, <span class="String">'</span><span class="Constant">$1</span><span class="String">'</span>)
pdirname <span class="Operator">:=</span> <span class="Function">replace_regex</span>(p2, <span class="String">'/([^/]*)$'</span>, <span class="String">'</span><span class="Identifier">$1</span><span class="String">'</span>)
param <span class="Operator">:=</span> <span class="Function">semver_matches</span>(<span class="String">'0.1.1'</span>, <span class="String">'&gt;=0.1.0'</span>)

<span class="Special">@</span><span class="Function">foo1</span> <span class="Identifier">param1</span> <span class="Identifier">param2</span><span class="Operator">=</span><span class="String">"default test"</span> <span class="Statement">+</span><span class="Identifier">varparam</span><span class="Operator">=</span><span class="String">'default'</span><span class="Operator">:</span> <span class="Function">dependency1</span> <span class="Delimiter">(</span><span class="Function">dependency2</span> p1 p2<span class="Delimiter">)</span> <span class="Delimiter">(</span><span class="Function">dependency3</span> param<span class="Delimiter">)</span>
Expand Down
20 changes: 10 additions & 10 deletions tests/cases/replace_regex-captures.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foo <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="Function">justfile</span>(), <span class="String">'[^A-Za-z]([A-Za-z]+)\.just$'</span>, <span class="String">' - Test </span><span class="Constant">$1</span><span class="String">'</span>)
foo <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="Function">justfile</span>(), <span class="String">'[^A-Za-z]([A-Za-z]+)\.just$'</span>, <span class="String">' - Test </span><span class="Identifier">$1</span><span class="String">'</span>)

foo2 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"""</span>
<span class="String"> </span><span class="Special">\t</span><span class="String">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed</span>
Expand All @@ -9,38 +9,38 @@
<span class="String"> quod angatur. Optime vero Epicurus, quod exiguam dixit</span>
<span class="String"> fortunam intervenire sapienti maximasque ab eo dissentiunt,</span>
<span class="String"> sed certe non.</span>
<span class="String">"""</span>, <span class="String">'\W(?P&lt;Abc1_&gt;\w{2})\W'</span>, <span class="String">" _</span><span class="Constant">$Abc1_</span><span class="String">-"</span>)
<span class="String">"""</span>, <span class="String">'\W(?P&lt;Abc1_&gt;\w{2})\W'</span>, <span class="String">" _</span><span class="Identifier">$Abc1_</span><span class="String">-"</span>)

foo3 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="Special">`echo ${HOME}`</span>, <span class="String">'/(\w+)/(\w+)'</span>, <span class="String">'</span><span class="Constant">${2}</span><span class="String">at</span><span class="Constant">${1}</span><span class="String">'</span>)
foo3 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="Special">`echo ${HOME}`</span>, <span class="String">'/(\w+)/(\w+)'</span>, <span class="String">'</span><span class="Identifier">${2}</span><span class="String">at</span><span class="Identifier">${1}</span><span class="String">'</span>)

foo4 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">'$T$es$t'</span>,
<span class="String">'\$([tT])'</span>
,
<span class="String">'</span><span class="Constant">$1</span><span class="String">'</span>
<span class="String">'</span><span class="Identifier">$1</span><span class="String">'</span>
)

foo5 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"any</span><span class="Special">\n</span><span class="String">$123"</span>, <span class="String">'\$123'</span>, <span class="String">"""</span>
<span class="Special">\t</span><span class="String">$$abc$</span>
<span class="String">234</span><span class="Special">\</span>
<span class="String">345 </span><span class="Constant">${456}</span><span class="String">567</span>
<span class="String">345 </span><span class="Identifier">${456}</span><span class="String">567</span>
<span class="String">"""</span>)

foo6 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"Some text."</span>, <span class="String">'([^a-z])'</span>, <span class="String">'$$</span><span class="Constant">$1</span><span class="String">$$2'</span>)
foo6 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"Some text."</span>, <span class="String">'([^a-z])'</span>, <span class="String">'$$</span><span class="Identifier">$1</span><span class="String">$$2'</span>)

foo7 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"Some text."</span>, <span class="String">'([^a-z])'</span>, <span class="String">'$$1'</span>)

foo8 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"test123"</span>, <span class="String">'\w(\d+)'</span>, <span class="String">'''</span>
<span class="String"> \t'</span><span class="Constant">$1</span><span class="String">'''</span>)
<span class="String"> \t'</span><span class="Identifier">$1</span><span class="String">'''</span>)

foo9 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"trailing comma is accepted after the final argument,"</span>,
<span class="String">"(</span><span class="Special">\\</span><span class="String">W+)"</span>, <span class="Special">\</span>
<span class="String">"</span><span class="Constant">${1}</span><span class="String">_</span><span class="Constant">$1</span><span class="String">"</span>,
<span class="String">"</span><span class="Identifier">${1}</span><span class="String">_</span><span class="Identifier">$1</span><span class="String">"</span>,
)

foo10 <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">"_abcdef"</span>,
<span class="String">'(\w)[a-z]+'</span>, <span class="Special">\</span>

<span class="String">'</span><span class="Constant">${1}</span><span class="String">'</span>
<span class="String">'</span><span class="Identifier">${1}</span><span class="String">'</span>
, <span class="Special">\</span>
)

Expand All @@ -55,5 +55,5 @@
replacement_split <span class="Operator">:=</span> <span class="Function">replace_regex</span>(<span class="String">'012034'</span>, <span class="String">'(?P&lt;capture&gt;[1-9]+)'</span>, <span class="String">"!$cap"</span> <span class="Operator">+</span> <span class="String">'ture'</span> <span class="Operator">+</span> <span class="String">'$captu'</span> <span class="Operator">/</span> <span class="String">"re"</span>)

<span class="Function">replacement_in_interp</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Delimiter">{{</span><span class="Function">replace_regex</span>(<span class="String">'A b c d'</span><span class="Normal">, </span><span class="String">'\s(\w)'</span><span class="Normal">, </span><span class="String">'1</span><span class="Constant">$1</span><span class="String">'</span>)<span class="Delimiter">}}</span><span class="String">'</span>
<span class="Number"> echo </span><span class="String">'</span><span class="Delimiter">{{</span><span class="Function">replace_regex</span>(<span class="String">'A b c d'</span><span class="Normal">, </span><span class="String">'\s(\w)'</span><span class="Normal">, </span><span class="String">'1</span><span class="Identifier">$1</span><span class="String">'</span>)<span class="Delimiter">}}</span><span class="String">'</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">replace_regex</span>(<span class="Identifier">replacement_conditional</span><span class="Normal">, </span><span class="String">'(\d+)'</span><span class="Normal">, </span><span class="Identifier">foo3</span>)<span class="Delimiter">}}</span>
2 changes: 1 addition & 1 deletion tests/cases/tricky.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
not_a_uuid_anymore <span class="Operator">:=</span> <span class="Function">replace_regex</span> (
<span class="Function">uuid</span> (
), <span class="String">'-4([0-9A-Fa-f]{3})-'</span>
, <span class="String">'_9</span><span class="Constant">${1}</span><span class="String">_'</span>
, <span class="String">'_9</span><span class="Identifier">${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> {
Expand Down

0 comments on commit 88d81ff

Please sign in to comment.