From 53d3b9027a6e4d886e583538013caf52c2548e54 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Fri, 29 Dec 2023 15:50:21 -0500 Subject: [PATCH] Add optional modules and imports --- syntax/just.vim | 13 +++++++++---- tests/cases/import.html | 2 +- tests/cases/import.just | 2 +- tests/cases/mod.html | 4 ++++ tests/cases/mod.just | 4 ++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 10933f5..c110c90 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -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 @@ -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 @@ -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 diff --git a/tests/cases/import.html b/tests/cases/import.html index 210c500..c0db306 100644 --- a/tests/cases/import.html +++ b/tests/cases/import.html @@ -3,5 +3,5 @@ import\ 'line-continuations.just' -import """ +import ? """ tricky.just""" diff --git a/tests/cases/import.just b/tests/cases/import.just index 3ebc3d2..39e633e 100644 --- a/tests/cases/import.just +++ b/tests/cases/import.just @@ -3,5 +3,5 @@ import 'recipes-simple.just' import\ 'line-continuations.just' -import """ +import ? """ tricky.just""" diff --git a/tests/cases/mod.html b/tests/cases/mod.html index 0837997..520a800 100644 --- a/tests/cases/mod.html +++ b/tests/cases/mod.html @@ -7,3 +7,7 @@ mod _foo-Foo \ 'foo/foo.just' + +mod? foo + +mod ? foo 'foo/justfile' diff --git a/tests/cases/mod.just b/tests/cases/mod.just index a9fe0b1..a50cc78 100644 --- a/tests/cases/mod.just +++ b/tests/cases/mod.just @@ -7,3 +7,7 @@ mod foo "foo/justfile" mod _foo-Foo \ 'foo/foo.just' + +mod? foo + +mod ? foo 'foo/justfile'