Skip to content

Commit

Permalink
Add optional modules and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Dec 29, 2023
1 parent c036848 commit 53d3b90
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
13 changes: 9 additions & 4 deletions syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,19 @@ syn cluster justExprInInterp contains=@justExprBase,justName,justExprParenInInte

syn cluster justExprFunc contains=@justBuiltInFunctions,justReplaceRegex,justExprParen

syn match justImport /\v^import\ze%(\s|\\\n)+['"]@=/
syn match justImport /\v^import%(%(\s|\\\n)*\?|%(\s|\\\n)+['"]@=)/ transparent
\ contains=justImportStatement,justOptionalFile
syn match justImportStatement '^import' contained

syn match justOldInclude "^!include\s.*$" contains=justOldIncludeDirective
syn match justOldIncludeDirective "^!include" contained

syn match justModule /\v^mod%(\s|\\\n)+\h\k*\s*%($|%(\s|\\\n)+['"]@=)/
\ transparent contains=justModStatement,justName
syn match justModule /\v^mod%(%(\s|\\\n)*\?)?%(\s|\\\n)+\h\k*\s*%($|%(\s|\\\n)+['"]@=)/
\ transparent contains=justModStatement,justName,justOptionalFile
syn match justModStatement '^mod' contained

syn match justOptionalFile '\V?' contained

hi def link justAlias Statement
hi def link justAssignmentOperator Operator
hi def link justBacktick Special
Expand All @@ -260,7 +264,7 @@ hi def link justConditional Conditional
hi def link justCurlyBraces Special
hi def link justExport Statement
hi def link justFunction Function
hi def link justImport Include
hi def link justImportStatement Include
hi def link justIndentError Error
hi def link justInterpolation Normal
hi def link justInterpolationDelim Delimiter
Expand All @@ -271,6 +275,7 @@ hi def link justName Identifier
hi def link justOldInclude PreProc
hi def link justOldIncludeDirective Underlined
hi def link justOperator Operator
hi def link justOptionalFile Conditional
hi def link justParameterError Error
hi def link justParameterOperator Operator
hi def link justParamExport Statement
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<span class="Include">import</span><span class="Special">\</span>
<span class="String">'line-continuations.just'</span>

<span class="Include">import</span> <span class="String">"""</span>
<span class="Include">import</span> <span class="Conditional">?</span> <span class="String">"""</span>
<span class="String"> tricky.just"""</span>
2 changes: 1 addition & 1 deletion tests/cases/import.just
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import 'recipes-simple.just'
import\
'line-continuations.just'

import """
import ? """
tricky.just"""
4 changes: 4 additions & 0 deletions tests/cases/mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@

<span class="Keyword">mod</span> <span class="Identifier">_foo-Foo</span> <span class="Special">\</span>
<span class="String">'foo/foo.just'</span>

<span class="Keyword">mod</span><span class="Conditional">?</span> <span class="Identifier">foo</span>

<span class="Keyword">mod</span> <span class="Conditional">?</span> <span class="Identifier">foo</span> <span class="String">'foo/justfile'</span>
4 changes: 4 additions & 0 deletions tests/cases/mod.just
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ mod foo "foo/justfile"

mod _foo-Foo \
'foo/foo.just'

mod? foo

mod ? foo 'foo/justfile'

0 comments on commit 53d3b90

Please sign in to comment.