From 4125820598b4282291235f79e3b32c6f3a2351fd Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Tue, 26 Dec 2023 10:42:17 -0500 Subject: [PATCH] Improve highlighting of recipe attributes: - Highlight separating commas differently from recipe attribute names - Fix highlighting of valid multi-line recipe attribute constructs without line continuations --- syntax/just.vim | 10 +++++++++- tests/cases/line-continuations.html | 8 ++++---- tests/cases/recipes-with-extras.html | 17 +++++++++++++---- tests/cases/recipes-with-extras.just | 9 +++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 4d4f033..5b4478b 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -57,7 +57,14 @@ syn region justExprParenInInterp start='\V(' end='\V)' transparent contained con syn match justRecipeAt "^@" contained syn match justRecipeColon ":" contained -syn match justRecipeAttr '^\v\[%(\s|\\\n)*%(confirm|no-%(cd|exit-message)|linux|macos|unix|windows|private)%(%(\s|\\\n)*,%(\s|\\\n)*%(confirm|no-%(cd|exit-message)|linux|macos|unix|windows|private))*%(\s|\\\n)*\]' +syn region justRecipeAttributes + \ matchgroup=justRecipeAttr start='\v^%(\\\n)@3# the trailing space after the closing ] is intentional [\ - no-cd \ - \ -, unix \ - ] + no-cd \ + \ +, unix \ + ] test7: pwd diff --git a/tests/cases/recipes-with-extras.html b/tests/cases/recipes-with-extras.html index eafa255..b474fc7 100644 --- a/tests/cases/recipes-with-extras.html +++ b/tests/cases/recipes-with-extras.html @@ -42,18 +42,27 @@ error: sh -c 'echo Exit 3;exit 3' -[ unix ] -[ macos,windows, linux ] +[ unix ] +[ macos,windows, linux ] any: echo foo -[ private ,no-cd , unix] -[no-exit-message ] +[ private ,no-cd , unix] +[no-exit-message ] runpwd_then_error: pwd sh -c 'exit 2' echo unreachable +[ + private + , + + confirm + ] +multiline-attr-no-continuations: + /bin/true + somevar := "1" interp_with_func_with_arg foo: echo {{quote(foo)}} diff --git a/tests/cases/recipes-with-extras.just b/tests/cases/recipes-with-extras.just index 951d6cf..4deed58 100644 --- a/tests/cases/recipes-with-extras.just +++ b/tests/cases/recipes-with-extras.just @@ -54,6 +54,15 @@ runpwd_then_error: sh -c 'exit 2' echo unreachable +[ + private + , + + confirm + ] +multiline-attr-no-continuations: + /bin/true + somevar := "1" interp_with_func_with_arg foo: echo {{quote(foo)}}