From bc965c8a00cd94cdf36416cb9e4c5ad8185e3292 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Sun, 24 Dec 2023 23:25:38 -0500 Subject: [PATCH] Optimize performance --- syntax/just.vim | 74 +++++++++++++++++++++++----------------- tests/cases/invalid.html | 5 --- tests/cases/invalid.just | 5 --- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/syntax/just.vim b/syntax/just.vim index 7240657..f062086 100644 --- a/syntax/just.vim +++ b/syntax/just.vim @@ -11,11 +11,13 @@ endif let b:current_syntax = 'just' syn sync fromstart +syn iskeyword @,48-57,_,- + syn match justComment "\v#%([^!].*)?$" contains=@Spell,justCommentTodo syn keyword justCommentTodo TODO FIXME XXX contained syn match justShebang "#!.*$" contains=justInterpolation -syn match justName "\h[a-zA-Z0-9_-]*" contained -syn match justFunction "\h[a-zA-Z0-9_-]*" contained +syn match justName "\h\k*" contained +syn match justFunction "\h\k*" contained syn match justPreBodyComment "\v%(\s|\\\n)*#%([^!].*)?\n%(\t+| +)@=" transparent contained contains=justComment \ nextgroup=@justBodies skipnl @@ -47,7 +49,7 @@ syn region justStringInShebangBody start=/\v\\@1%(%(\s|\\\n)*\=)@!" contained +syn match justParameterError "\v%(%([+*$]+%(\s|\\\n)*)*\h\k*)@>%(%(\s|\\\n)*\=)@!" contained syn region justRecipeParenDefault \ matchgroup=justRecipeDepParamsParen start='\v%(\=%(\s|\\\n)*)@<=\(' end='\V)' \ contained \ contains=@justExpr -syn match justRecipeSubsequentDeps '&&' contained +syn match justRecipeSubsequentDeps '\V&&' contained syn match justRecipeNoDeps '\v:%(\s|\\\n)*\n|:#@=|:%(\s|\\\n)+#@=' \ transparent contained @@ -109,46 +111,52 @@ syn region justRecipeDeps start="\v:%(\s|\\\n)*%([a-zA-Z_(]|\&\&)" skip='\\\n' e syn region justRecipeParamDep contained transparent \ matchgroup=justRecipeDepParamsParen - \ start="(" - \ end=")" + \ start="\V(" + \ end="\V)" \ contains=justRecipeDepParenName,@justExpr syn keyword justBoolean true false contained -syn match justAssignment "\v^\h[a-zA-Z0-9_-]*%(\s|\\\n)*:\=" transparent contains=justAssignmentOperator +syn match justAssignment "\v^\h\k*%(\s|\\\n)*:\=" transparent contains=justAssignmentOperator -syn match justSet '\v^set%(\s|\\\n)@=' contained -syn match justSetKeywords "\vallow-duplicate-recipes|dotenv-%(load|filename|path)|export|fallback|ignore-comments|positional-arguments|tempdir|%(windows-)?shell" contained -syn match justSetDeprecatedKeywords 'windows-powershell' contained +syn match justSet '\v^set' contained +syn keyword justSetKeywords + \ allow-duplicate-recipes dotenv-load dotenv-filename dotenv-path export fallback ignore-comments positional-arguments shell tempdir windows-shell + \ contained +syn keyword justSetDeprecatedKeywords windows-powershell contained syn match justBooleanSet "\v^set%(\s|\\\n)+%(allow-duplicate-recipes|dotenv-load|export|fallback|ignore-comments|positional-arguments|windows-powershell)%(%(\s|\\\n)*:\=%(\s|\\\n)*%(true|false))?$" \ contains=justSet,justSetKeywords,justSetDeprecatedKeywords,justAssignmentOperator,justBoolean \ transparent -syn match justStringSet '\v^set%(\s|\\\n)+%(dotenv-%(filename|path)|tempdir)%(\s|\\\n)*:\=%(\s|\\\n)*%(['"])@=' transparent contains=justSet,justSetKeywords,justAssignmentOperator +syn match justStringSet '\v^set%(\s|\\\n)+\k+%(\s|\\\n)*:\=%(\s|\\\n)*%(['"])@=' transparent contains=justSet,justSetKeywords,justAssignmentOperator -syn region justShellSet - \ start="\v^set%(\s|\\\n)+%(windows-)?shell%(\s|\\\n)*:\=%(\s|\\\n)*\[" - \ end="]" - \ contains=justSet,justSetKeywords,justAssignmentOperator,justString,justRawString,justSetError +syn match justShellSet + \ "\v^set%(\s|\\\n)+%(windows-)?shell%(\s|\\\n)*:\=%(\s|\\\n)*\[@=" + \ contains=justSet,justSetKeywords,justAssignmentOperator \ transparent skipwhite + \ nextgroup=justShellSetValue +syn region justShellSetValue + \ start='\V[' end='\V]' + \ contained + \ contains=justString,justRawString,justShellSetError -syn match justSetError '\v%(%(\[|,)\_s*)@<=[^'"\][:space:]][^,\][:space:]]*|\[\_s*\]' contained +syn match justShellSetError '\v\k+' contained -syn match justAlias '\v^alias%(\s|\\\n)@=' contained -syn match justAliasDecl "\v^alias%(\s|\\\n)+\h[a-zA-Z0-9_-]*%(\s|\\\n)*:\=%(\s|\\\n)*" +syn match justAlias '\v^alias' contained +syn match justAliasDecl "\v^alias%(\s|\\\n)+\h\k*%(\s|\\\n)*:\=%(\s|\\\n)*" \ transparent \ contains=justAlias,justFunction,justAssignmentOperator \ nextgroup=justAliasRes -syn match justAliasRes '\v\h[a-zA-Z0-9_-]*%(\s|\\\n)*%(#@=|$)' contained transparent contains=justFunction +syn match justAliasRes '\v\h\k*%(\s|\\\n)*%(#@=|$)' contained transparent contains=justFunction -syn match justExportedAssignment "\v^export%(\s|\\\n)+\h[a-zA-Z0-9_-]*\s*:\=" transparent +syn match justExportedAssignment "\v^export%(\s|\\\n)+\h\k*\s*:\=" transparent \ contains=justExport,justAssignmentOperator -syn match justExport '\v^export%(\s|\\\n)@=' contained +syn match justExport '\v^export' contained syn keyword justConditional if else -syn region justConditionalBraces start="\v\{@1set shell -set shell := [] -set shell := [ ] -set shell := [ - -] bash := 'bash' c := '-c' diff --git a/tests/cases/invalid.just b/tests/cases/invalid.just index 8c2595b..f618cab 100644 --- a/tests/cases/invalid.just +++ b/tests/cases/invalid.just @@ -1,11 +1,6 @@ !include not-at-beginning-of-line.just set shell -set shell := [] -set shell := [ ] -set shell := [ - -] bash := 'bash' c := '-c'