Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just 1.15.0 syntaxes #49

Merged
merged 14 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ftplugin/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" Language: Justfile
" Maintainer: Noah Bogart <noah.bogart@hey.com>
" 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")
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ functionsWithArgs := '''
absolute_path
capitalize
clean
env
env_var
env_var_or_default
extension
Expand Down Expand Up @@ -110,10 +111,12 @@ zeroArgFunctions := '''
just_executable
justfile
justfile_directory
num_cpus
os
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:
Expand Down
161 changes: 95 additions & 66 deletions syntax/just.vim

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions tests/cases/alias.html

This file was deleted.

4 changes: 0 additions & 4 deletions tests/cases/alias.just

This file was deleted.

11 changes: 11 additions & 0 deletions tests/cases/invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<span class="Error"> abc def</span>
<span class="Error">)</span>

badfunc5 <span class="Operator">:=</span> <span class="Error">num_cpus(\)</span>

not_a_recipe_name <span class="Comment">#comment:</span>
not a recipe body

Expand All @@ -53,6 +55,15 @@
<span class="Number"> echo </span><span class="String">'valid again</span>
<span class="String"> </span><span class="Error"> </span><span class="String">not valid'</span>

<span class="Function">bad_but_not_mixed_indentation</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'tab indent'</span>
echo <span class="String">'space indent'</span>
<span class="Function">bad_but_not_mixed_indentation_shebang</span><span class="Operator">:</span>
<span class="Number"> </span><span class="SpecialComment">#!/bin/bash</span>
<span class="Number"> echo </span><span class="String">'space indent, same as first line'</span>
<span class="Number"> echo </span><span class="String">'acceptable space indent'</span>
echo <span class="String">'tab indent'</span>

<span class="Function">bad_curly_braces</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Error">{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
<span class="Number"> echo </span><span class="Error">{{{{{</span><span class="Number">Odd number of opening curly braces is an error.}}</span>
Expand Down
11 changes: 11 additions & 0 deletions tests/cases/invalid.just
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ badfunc4 := justfile (
abc def
)

badfunc5 := num_cpus(\)

not_a_recipe_name #comment:
not a recipe body

Expand All @@ -53,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.}}
Expand Down
170 changes: 170 additions & 0 deletions tests/cases/line-continuations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<span class="Statement">set</span> <span class="Special">\</span>
<span class="Keyword">ignore-comments</span> <span class="Operator">:=</span> <span class="Boolean">true</span>

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


var <span class="Special">\</span>
<span class="Operator">:=</span><span class="Special">\</span>
<span class="String">'1'</span> <span class="Operator">+</span> <span class="String">'2'</span> <span class="Special">\</span>
<span class="Special">\</span>
<span class="Operator">+</span> <span class="String">'3'</span> <span class="Operator">/</span><span class="Special">\</span>
<span class="String">'456'</span> <span class="Operator">+</span> <span class="Special">\</span>
<span class="Conditional">if</span> <span class="Special">\</span>
<span class="String">'a'</span> <span class="Special">\</span>
<span class="Operator">!=</span> <span class="Special">\</span>
<span class="String">'b'</span> <span class="Special">\</span>
{<span class="Special">\</span>
<span class="String">'\789'</span>} <span class="Special">\</span>
<span class="Conditional">else</span><span class="Special">\</span>
{ <span class="String">'\543'</span><span class="Special">\</span>
<span class="Special">\</span>
}


f1 <span class="Operator">:=</span> <span class="Special">\</span>
<span class="Function">uuid</span><span class="Special">\</span>
<span class="Special">\</span>
<span class="Special">\</span>
(<span class="Special">\</span>

)

f2 <span class="Operator">:=</span> <span class="Function">env</span> (<span class="Special">\</span>

<span class="String">'FOO_VAR'</span>, <span class="Special">\</span>

<span class="String">'0'</span><span class="Special">\</span>

)

f3 <span class="Operator">:=</span> <span class="Function">replace_regex</span> <span class="Special">\</span>
( <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="Special">\</span>
)

<span class="Function">test</span><span class="Operator">:</span> <span class="Function">a</span> <span class="Special">\</span>
<span class="Function">b</span>
<span class="Number"> echo </span><span class="String">'123'</span>

<span class="Function">a</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'A'</span>
<span class="Function">b</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'B'</span>
<span class="Function">c</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="String">'C'</span>
<span class="Number"> </span><span class="Comment"># ignored line</span>

<span class="Function">test2</span> <span class="Special">\</span>
<span class="Identifier">param1</span><span class="Operator">=</span><span class="String">"foo"</span> <span class="Identifier">param2</span> <span class="Special">\</span>
<span class="Operator">=</span> <span class="String">'''</span>
<span class="String">bar'''</span><span class="Special">\</span>
<span class="Identifier">param3</span> <span class="Operator">=</span> <span class="Special">\</span>
<span class="String">"b</span><span class="Special">\</span>
<span class="String">a</span><span class="Special">\</span>
<span class="String">z"</span> <span class="Special">\</span>
<span class="Special">\</span>
<span class="Statement">*</span> <span class="Special">\</span>
<span class="Statement">$</span> <span class="Special">\</span>
<span class="Identifier">param4</span> <span class="Special">\</span>
<span class="Operator">=</span> <span class="Special">\</span>
f1 <span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Identifier">param1</span><span class="Delimiter">}}</span><span class="Number"> </span><span class="Delimiter">{{</span><span class="Identifier">param2</span><span class="Delimiter">}}</span><span class="Number"> </span><span class="Delimiter">{{</span><span class="Identifier">param3</span><span class="Delimiter">}}</span><span class="Number"> </span><span class="Delimiter">{{</span><span class="Identifier">param4</span><span class="Delimiter">}}</span>

<span class="Function">test3</span><span class="Operator">:</span> <span class="Special">\</span>
<span class="Function">a</span> <span class="Function">b</span> <span class="Special">\</span>
<span class="Function">c</span> <span class="Comment">#comment \</span>
<span class="Number"> echo d</span>
<span class="Number"> echo </span><span class="String">'Test 3'</span>

<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="String">'bar'</span>

<span class="Delimiter">)</span>
<span class="Number"> env | grep -F PARAM</span>

<span class="Function">test5</span><span class="Operator">:</span> <span class="Function">a</span> <span class="Special">\</span>
<span class="Special">\</span>
<span class="Special">\</span>
<span class="Special">\</span>
<span class="Function">b</span>
<span class="Number"> echo </span><span class="String">'Test5'</span>

<span class="Function">test6</span><span class="Operator">:</span> <span class="Function">a</span><span class="Special">\</span>
<span class="Function">b</span>
<span class="Number"> echo </span><span class="String">'Test6'</span>

<span class="Comment"># the trailing space after the closing ] is intentional</span>
<span class="Type">[</span><span class="Special">\</span>
<span class="Type"> no-cd </span><span class="Special">\</span>
<span class="Type"> </span><span class="Special">\</span>
<span class="Type">, unix </span><span class="Special">\</span>
<span class="Type"> ]</span>
<span class="Function">test7</span><span class="Operator">:</span>
<span class="Number"> pwd</span>

<span class="Statement">alias</span><span class="Special">\</span>
<span class="Function">runpwd</span><span class="Special">\</span>
<span class="Operator">:=</span><span class="Special">\</span>
<span class="Function">test7</span>
foo <span class="Special">\</span>
<span class="Operator">:=</span> <span class="String">'Foo!'</span>

<span class="Function">test8</span> <span class="Identifier">param1</span> <span class="Special">\</span>
<span class="Operator">=</span> <span class="Special">\</span>
<span class="Delimiter">(</span> f1 <span class="Operator">+</span> <span class="String">'X'</span> <span class="Operator">+</span> f2<span class="Delimiter">)</span> <span class="Special">\</span>
<span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Normal"> </span><span class="Special">\</span>
<span class="Normal"> </span><span class="Identifier">param1</span><span class="Normal"> </span><span class="Special">\</span>
<span class="Normal"> </span><span class="Delimiter">}}</span>

<span class="Function">test9</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Special">\</span>
<span class="Normal"> </span><span class="Function">num_cpus</span><span class="Normal">(</span><span class="Special">\</span>
<span class="Normal"> ) </span><span class="Special">\</span>
<span class="Normal"> </span><span class="Delimiter">}}</span>

<span class="Function">test10</span> <span class="Identifier">param1</span><span class="Operator">=</span><span class="Special">\</span>
<span class="Function">num_cpus</span>() <span class="Special">\</span>
<span class="Special">\</span>
<span class="Identifier">param2</span><span class="Special">\</span>
<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="Function">env</span><span class="Special">\</span>
(<span class="String">'BAR'</span>,



<span class="Special">\</span>

<span class="Function">replace</span>(<span class="String">'fghi'</span>, <span class="String">'ghi'</span>, <span class="Special">\</span>
<span class="String">'foo'</span>)

)<span class="Operator">:</span> <span class="Special">\</span>
<span class="Comment"># comment \</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Identifier">param1</span><span class="Special">\</span>
<span class="Normal"> </span><span class="Operator">/</span><span class="Normal"> </span><span class="Identifier">param2</span><span class="Normal"> </span><span class="Delimiter">}}</span>
<span class="Number"> echo .</span>

<span class="Function">test11</span><span class="Operator">:</span> <span class="Function">a</span> <span class="Special">\</span>
<span class="Comment"># comment\</span>
<span class="Number"> echo Test 11</span>

<span class="Function">test12</span><span class="Operator">:</span> <span class="Special">\</span>

<span class="Number"> echo Test 12</span>

<span class="Function">test13</span><span class="Operator">:</span> <span class="Function">a</span><span class="Special">\</span>

<span class="Number"> echo Test13</span>
Loading