From 0b38c0089925db7111d75a93a75c79bbc9026329 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 27 Apr 2023 03:09:42 -0400 Subject: [PATCH] Syntax updates --- syntax/blang.vim | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/syntax/blang.vim b/syntax/blang.vim index f089ecd..e13792d 100644 --- a/syntax/blang.vim +++ b/syntax/blang.vim @@ -12,6 +12,9 @@ syn match BlangVar /[a-zA-Z_][a-zA-Z_0-9]*/ syn match BlangNumber /0x[0-9a-fA-F_]\+%\?\|[0-9][0-9_]*\(\.\([0-9][0-9_]*\|\.\@!\)\)\?\(e[0-9_]\+\)\?%\?\|\.\@/he=s-1 contains=BlangEscape contained syn region BlangDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=BlangStringInterp contained +syn region BlangDSLString start=/\//hs=e+1 end=/\//he=s-1 contains=BlangStringAtInterp contained syn region BlangDSLString start=/>.\@=/hs=e+1 end=/$/ contains=BlangStringAtInterp contained syn region BlangDSLString start=/>.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\%(\z1\s\)\@!.\@=/ contains=BlangStringAtInterp contained syn region BlangDSLString start=/:.\@=/hs=e+1 end=/$/ contains=BlangStringInterp,BlangEscape contained syn region BlangDSLString start=/:.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\%(\z1\s\)\@!.\@=/ contains=BlangStringInterp,BlangEscape contained hi def link BlangDSLString String -syn match BlangDSL /%\w\+/ nextgroup=BlangString,BlangDSLString +syn match BlangDocTest /^\s*\(>>>\|===\|!!!\)/ +hi BlangDocTest ctermfg=gray cterm=italic + +syn match BlangDocError /!!!.*/ +hi BlangDocError ctermfg=red cterm=italic + +syn match BlangDSL /\$\w*/ nextgroup=BlangString,BlangDSLString hi def link BlangDSL String hi BlangDSL ctermfg=white cterm=bold -syn match BlangStringDollar /\$/ contained +syn match BlangStringDollar /\$:\?/ contained hi BlangStringDollar ctermfg=LightBlue syn match BlangStringAt /@/ contained hi BlangStringAt ctermfg=LightBlue -syn match BlangStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*/ contained +syn match BlangStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*\(\.[a-zA-Z_][a-zA-Z_0-9]*\)*/ contained hi BlangStringInterpWord ctermfg=LightBlue -syn match BlangStringInterp /\$/ contained nextgroup=BlangStringDollar,BlangStringInterpWord,@BlangAll +syn match BlangStringInterp /\$:\?/ contained nextgroup=BlangStringDollar,BlangStringInterpWord,@BlangAll hi BlangStringInterp ctermfg=LightBlue syn match BlangStringAtInterp /@/ contained nextgroup=BlangStringAt,BlangStringInterpWord,@BlangAll @@ -52,10 +62,10 @@ hi BlangStringAtInterp ctermfg=LightBlue syn match BlangEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\)\(-\([abnrtv]\|x\x\x\|\d\{3}\)\)\?\|\\./ hi BlangEscape ctermfg=LightBlue -syn keyword BlangConditional if unless elseif else when then +syn keyword BlangConditional if unless elseif else when then defer hi def link BlangConditional Conditional -syn keyword BlangLoop for between while repeat do until +syn keyword BlangLoop for between while repeat do until with hi def link BlangLoop Repeat syn keyword BlangFail fail @@ -91,8 +101,8 @@ hi BlangStructName cterm=bold syn keyword BlangOperator in and or xor is not mod sizeof typeof syn match BlangOperator /\<\(and\|or\|xor\|mod\|in\)=/ -syn match BlangOperator /[+*/^<>=-]=\?/ -syn match BlangOperator /[:!]\?=/ +syn match BlangOperator /\(>>>\|===\)\@![+*/^<>=-]=\?/ +syn match BlangOperator /\(===\)\@![:!]\?=/ syn match BlangOperator /[#?]/ hi def link BlangOperator Operator @@ -106,10 +116,11 @@ hi def link BlangAssoc Type syn region BlangType start=/\[/ end=/\]\|$/ contains=BlangType contained syn region BlangType start=/{/ end=/}\|$/ contains=BlangType,BlangAssoc contained syn region BlangType start=/(/ end=/)=>\|$/ contains=BlangType,BlangTypeDelim nextgroup=BlangType contained -syn match BlangType /\w\+/ contained +syn match BlangType /[a-zA-Z_0-9@?]\+/ contained hi def link BlangType Type -syn match BlangTypeAnnotation /:=\@!/ nextgroup=BlangType skipwhite +syn match BlangTypeAnnotation /:\@/ nextgroup=BlangType skipwhite @@ -120,9 +131,13 @@ hi def link BlangComment Comment syn region BlangParenGroup start=/(/ end=/)/ contains=@BlangAll -syn cluster BlangAll contains=BlangComment,BlangString,BlangDSL,BlangKeyword,BlangOperator, +syn match BlangLinkerDirective ;^\s*!link.*$; +hi BlangLinkerDirective ctermbg=blue ctermfg=black + +syn cluster BlangAll contains=BlangVar,BlangComment,BlangChar,BlangString,BlangDSL,BlangKeyword,BlangOperator, \BlangConditional,BlangLoop,BlangFail,BlangStatement,BlangStructure,BlangTypedef, - \BlangNumber,BlangFnDecl,BlangBoolean,BlangNil,BlangTypeAnnotation,BlangAs,BlangParenGroup + \BlangNumber,BlangFnDecl,BlangBoolean,BlangNil,BlangTypeAnnotation,BlangAs,BlangParenGroup,BlangDocTest,BlangDocError + \BlangLinkerDirective if !exists('b:current_syntax') let b:current_syntax = 'bpeg'