Syntax tweaks

This commit is contained in:
Bruce Hill 2024-11-26 01:01:01 -05:00
parent 2262f6bbf6
commit 7b94c5fe2c
3 changed files with 56 additions and 48 deletions

View File

@ -10,6 +10,6 @@ let b:did_ftplugin = 1
setlocal formatoptions-=t setlocal formatoptions-=t
setlocal cpoptions+=M setlocal cpoptions+=M
setlocal commentstring=//\ %s setlocal commentstring=#\ %s
let b:undo_ftplugin = "setlocal formatoptions< cpoptions<" let b:undo_ftplugin = "setlocal formatoptions< cpoptions<"

View File

@ -24,7 +24,7 @@ function! GetSSSIndent()
let previous = getline(previousNum) let previous = getline(previousNum)
let ind = indent(previousNum) let ind = indent(previousNum)
if previous =~ '\(^\s*\<\(for\|while\|if\|else\|elseif\|between\|def\)\>\)\|[:=]\s*$' if previous =~ '\(^\s*\<\(for\|while\|if\|else\|elseif\|between\|def\)\>\)\|^[^#]*[:=]\s*$'
let ind = ind + &tabstop let ind = ind + &tabstop
endif endif

View File

@ -18,25 +18,28 @@ hi def link SSSNumber Number
syn match SSSChar /`./ syn match SSSChar /`./
hi def link SSSChar String hi def link SSSChar String
syn region SSSString start=/".\@=/ end=/"\|$/ contains=SSSEscape,SSSStringInterp syn region SSSString start=/".\@=/ end=/"\|$/ contains=SSSStringInterp
syn region SSSString start=/'.\@=/ end=/'\|$/ syn region SSSString start=/'.\@=/ end=/'\|$/
syn region SSSString start=/".\@!\%(^\z(\s*\).*\)\@<=/ end=/^\z1"\|^\%(\z1\s\)\@!\s*\S\@=/ contains=SSSEscape,SSSStringInterp syn region SSSString start=/`.\@=/ end=/`\|$/ contains=SSSStringInterp
syn region SSSString start=/".\@!\%(^\z(\s*\).*\)\@<=/ end=/^\z1"\|^\%(\z1\s\)\@!\s*\S\@=/ contains=SSSStringInterp
syn region SSSString start=/'.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\z1'\|^\%(\z1\s\)\@!\s*\S\@=/he=s-1 syn region SSSString start=/'.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\z1'\|^\%(\z1\s\)\@!\s*\S\@=/he=s-1
syn region SSSString start=/`.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\z1`\|^\%(\z1\s\)\@!\s*\S\@=/he=s-1
hi def link SSSString String hi def link SSSString String
syn region SSSDSLString start=/\z(\W\).\@=/hs=e end=/\z1/ contains=SSSEscape,SSSStringInterp contained syn region SSSPath start=;(\(\~/\|./\|../\|/\); skip=/\\.\|([^)]*)/ end=;$\|); contains=SSSStringInterp,SSSEscape
syn region SSSDSLString start=/\z(\W\).\@!\%(^\z(\s*\).*\)\@<=/hs=e end=/^\z2\z1/he=e contains=SSSEscape,SSSStringInterp contained hi def link SSSPath String
syn region SSSDSLString start=/\[/hs=e+1 end=/]/he=s-1 contains=SSSEscape,SSSStringInterp contained
syn region SSSDSLString start=/\z(["'`|/;([{<]\).\@=/hs=e end=/\z1/ contains=SSSStringInterp contained
syn region SSSDSLString start=/\z(["'`|/;([{<]\).\@!\%(^\z(\s*\).*\)\@<=/hs=e end=/^\z2\z1/he=e contains=SSSStringInterp contained
syn region SSSDSLString start=/\[/hs=e+1 end=/]/he=s-1 contains=SSSStringInterp contained
syn region SSSDSLString start=/{/hs=e+1 end=/}/he=s-1 contained syn region SSSDSLString start=/{/hs=e+1 end=/}/he=s-1 contained
syn region SSSDSLString start=/</hs=e+1 end=/>/he=s-1 contains=SSSEscape contained syn region SSSDSLString start=/</hs=e+1 end=/>/he=s-1 contains= contained
syn region SSSDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=SSSStringInterp contained syn region SSSDSLString start=/(/hs=e+1 end=/)/he=s-1 contains=SSSStringInterp contained
syn region SSSDSLString start=/\//hs=e+1 end=/\//he=s-1 contains=SSSStringAtInterp contained
syn region SSSDSLString start=/>.\@=/hs=e+1 end=/$/ contains=SSSStringAtInterp contained
syn region SSSDSLString start=/>.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\%(\z1\s\)\@!.\@=/ contains=SSSStringAtInterp contained
syn region SSSDSLString start=/:.\@=/hs=e+1 end=/$/ contains=SSSStringInterp,SSSEscape contained
syn region SSSDSLString start=/:.\@!\%(^\z(\s*\).*\)\@<=/hs=e+1 end=/^\%(\z1\s\)\@!.\@=/ contains=SSSStringInterp,SSSEscape contained
hi def link SSSDSLString String hi def link SSSDSLString String
syn match SSSArray /\[/ nextgroup=SSSTypeAnnotation
syn match SSSTable /{/ nextgroup=SSSTypeAnnotation
syn match SSSDocTest /^\s*>>>/ syn match SSSDocTest /^\s*>>>/
syn region SSSDocTest start=/^\s*===/ end=/$/ syn region SSSDocTest start=/^\s*===/ end=/$/
hi SSSDocTest ctermfg=gray hi SSSDocTest ctermfg=gray
@ -44,25 +47,25 @@ hi SSSDocTest ctermfg=gray
syn match SSSDocError /!!!.*/ syn match SSSDocError /!!!.*/
hi SSSDocError ctermfg=red cterm=italic hi SSSDocError ctermfg=red cterm=italic
syn match SSSDSL /\$\w*/ nextgroup=SSSString,SSSDSLString syn match SSSDSL /\$\w*/ nextgroup=SSSString,SSSCustomStringInterp
hi def link SSSDSL String hi def link SSSDSL String
hi SSSDSL ctermfg=white cterm=bold hi SSSDSL ctermfg=white cterm=bold
syn match SSSCustomStringInterp /[~!@#$%^&*+=\?]\?/ contained nextgroup=SSSDSLString
hi SSSCustomStringInterp ctermfg=gray
syn match SSSStringDollar /\$:\?/ contained syn match SSSStringDollar /\$:\?/ contained
hi SSSStringDollar ctermfg=LightBlue hi SSSStringDollar ctermfg=LightBlue
syn match SSSStringAt /@/ contained syn match SSSStringAt /@/ contained
hi SSSStringAt ctermfg=LightBlue hi SSSStringAt ctermfg=LightBlue
syn match SSSStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*\(\.[a-zA-Z_][a-zA-Z_0-9]*\)*/ contained syn match SSSStringInterpWord /[a-zA-Z_][a-zA-Z_0-9]*/ contained
hi SSSStringInterpWord ctermfg=LightBlue hi SSSStringInterpWord ctermfg=LightBlue
syn match SSSStringInterp /\$:\?/ contained nextgroup=SSSStringDollar,SSSStringInterpWord,SSSParenGroup,@SSSAll syn match SSSStringInterp /\$:\?/ contained nextgroup=SSSStringDollar,SSSStringInterpWord,SSSParenGroup,@SSSAll
hi SSSStringInterp ctermfg=LightBlue hi SSSStringInterp ctermfg=LightBlue
syn match SSSStringAtInterp /@/ contained nextgroup=SSSStringAt,SSSStringInterpWord,SSSParenGroup,@SSSAll
hi SSSStringAtInterp ctermfg=LightBlue
syn match SSSEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\)\(-\([abnrtv]\|x\x\x\|\d\{3}\)\)\?\|\\./ syn match SSSEscape /\\\([abenrtvN]\|x\x\x\|\d\{3}\)\(-\([abnrtv]\|x\x\x\|\d\{3}\)\)\?\|\\./
hi SSSEscape ctermfg=LightBlue hi SSSEscape ctermfg=LightBlue
@ -72,34 +75,31 @@ hi def link SSSExtern Statement
syn keyword SSSConditional if unless elseif else when then defer convert syn keyword SSSConditional if unless elseif else when then defer convert
hi def link SSSConditional Conditional hi def link SSSConditional Conditional
syn keyword SSSLoop for between while repeat do until with syn keyword SSSLoop for between while do until with repeat
hi def link SSSLoop Repeat hi def link SSSLoop Repeat
syn keyword SSSFail fail syn keyword SSSFail fail
hi def link SSSFail Exception hi def link SSSFail Exception
syn keyword SSSStatement stop skip fail pass return del struct syn keyword SSSStatement stop skip fail pass return del struct lang
hi def link SSSStatement Statement hi def link SSSStatement Statement
syn keyword SSSNull NONE
hi SSSNull ctermfg=red
syn region SSSUse matchgroup=Keyword start=/\<use\>/ matchgroup=SSSDelim end=/$\|;/ syn region SSSUse matchgroup=Keyword start=/\<use\>/ matchgroup=SSSDelim end=/$\|;/
hi def link SSSUse String hi def link SSSUse String
syn keyword SSSExtend extend nextgroup=SSSType skipwhite
hi def link SSSExtend Keyword
syn match SSSArgDefault /=/ nextgroup=@SSSAll skipwhite contained syn match SSSArgDefault /=/ nextgroup=@SSSAll skipwhite contained
hi def link SSSArgDefault Operator hi def link SSSArgDefault Operator
syn match SSSReturnSignature /->/ nextgroup=SSSType skipwhite contained syn match SSSReturnSignature /->/ nextgroup=SSSType skipwhite contained
hi def link SSSReturnSignature Operator hi def link SSSReturnSignature Operator
syn region SSSFnArgSignature start=/(/ end=/)/ contains=SSSVar,SSSTypeAnnotation,SSSDelim,SSSArgDefault nextgroup=SSSReturnSignature skipwhite contained syn region SSSFnArgSignature start=/(/ end=/)/ contains=SSSVar,SSSDelim,SSSTypeAnnotation,SSSArgDefault nextgroup=SSSReturnSignature skipwhite contained
syn match SSSFnName /\<[a-zA-Z_][a-zA-Z_0-9]*\>/ nextgroup=SSSFnArgSignature skipwhite contained syn match SSSFnName /\<[a-zA-Z_][a-zA-Z_0-9]*\>/ nextgroup=SSSFnArgSignature skipwhite contained
hi def link SSSFnName Function hi def link SSSFnName Function
syn keyword SSSFuncDef func nextgroup=SSSFnName skipwhite syn keyword SSSFuncDef func nextgroup=SSSFnName skipwhite
hi def link SSSFuncDef Keyword hi def link SSSFuncDef Keyword
syn keyword SSSKeyword alias unit
hi def link SSSKeyword Keyword
syn match SSSTagEquals /=/ skipwhite nextgroup=SSSErrorWord,SSSNumber contained syn match SSSTagEquals /=/ skipwhite nextgroup=SSSErrorWord,SSSNumber contained
hi def link SSSTagEquals Operator hi def link SSSTagEquals Operator
syn match SSSTagType /(/ nextgroup=SSSType contained syn match SSSTagType /(/ nextgroup=SSSType contained
@ -121,49 +121,57 @@ hi SSSNil cterm=bold ctermfg=cyan
syn match SSSStructName /\w\+\( *{\)\@=/ syn match SSSStructName /\w\+\( *{\)\@=/
hi SSSStructName cterm=bold hi SSSStructName cterm=bold
syn keyword SSSOperator of in by and or xor is not mod mod1 sizeof typeof bitcast _min_ _max_ _mix_ syn keyword SSSOperator in and or xor is not mod mod1 _min_ _max_ _mix_
syn match SSSOperator /\(>>>\|===\)\@![+*/^<>=-]=\?/ syn match SSSOperator ;\([a-zA-Z0-9_)] *\)\@<=/;
syn match SSSOperator /\(===\)\@![:!]\?=/ syn match SSSOperator ;[+*^<>=-]=\?;
syn match SSSOperator /[#?]/ syn match SSSOperator /[:!]\?=/
syn match SSSOperator /[#?:]/
hi def link SSSOperator Operator hi def link SSSOperator Operator
syn match SSSDelim /,/ syn match SSSDelim /,/
hi def link SSSDelim Delimiter hi def link SSSDelim Delimiter
syn match SSSTableValueType /=>/ nextgroup=SSSType contained syn match SSSTableValueType /:/ nextgroup=SSSType contained
hi def link SSSTableValueType Type hi def link SSSTableValueType Type
syn match SSSTypeDelim /,/ contained syn match SSSTypeDelim /,/ contained
hi def link SSSTypeDelim Type hi def link SSSTypeDelim Type
syn match SSSAssoc /=/ contained syn match SSSAssoc /=/ contained
hi def link SSSAssoc Type hi def link SSSAssoc Type
syn region SSSTypeUnits start=/</ end=/>/ contained syn region SSSType start=/\[/ end=/\]\|\():\)\@=\|$/ contains=SSSType contained nextgroup=SSSTableValueType
hi def link SSSTypeUnits Type syn region SSSType start=/{/ end=/}\|\():\)\@=\|$/ contains=SSSType,SSSAssoc contained nextgroup=SSSTableValueType
syn region SSSType start=/\[/ end=/\]\|$/ contains=SSSType contained nextgroup=SSSTableValueType,SSSTypeUnits syn region SSSType start=/func(/ end=/) *\(->\)\?/ contains=SSSType,SSSTypeDelim nextgroup=SSSType contained
syn region SSSType start=/{/ end=/}\|$/ contains=SSSType,SSSAssoc contained nextgroup=SSSTableValueType,SSSTypeUnits syn match SSSType /[a-zA-Z_]\i*/ contained nextgroup=SSSTableValueType
syn region SSSType start=/(/ end=/) *->/ contains=SSSType,SSSTypeDelim nextgroup=SSSType contained syn match SSSType /\$[a-zA-Z_0-9]\+/ contained nextgroup=SSSTableValueType
syn match SSSType /[a-zA-Z_]\i*/ contained nextgroup=SSSTableValueType,SSSTypeUnits
syn match SSSType /\$[a-zA-Z_0-9]\+/ contained nextgroup=SSSTableValueType,SSSTypeUnits
syn match SSSType /[@?&]\+/ contained nextgroup=SSSType syn match SSSType /[@?&]\+/ contained nextgroup=SSSType
hi def link SSSType Type hi def link SSSType Type
syn match SSSTypeAnnotation /:\@<!:[=:]\@!/ nextgroup=SSSType syn match SSSTypeAnnotation /:=\@!/ nextgroup=SSSType contained
hi def link SSSTypeAnnotation Operator hi def link SSSTypeAnnotation Operator
syn keyword SSSAs as nextgroup=SSSType skipwhite syn region SSSComment start=;#; end=/$/
hi def link SSSAs Operator
syn region SSSComment start=;//; end=/$/
hi def link SSSComment Comment hi def link SSSComment Comment
syn region SSSSay start=;!!; end=/$/ contains=SSSEscape,SSSStringInterp
hi SSSSay ctermfg=white cterm=bold
syn region SSSInlineCParens start=/(/ end=/)/ contains=SSSInlineCParens contained
hi def link SSSInlineCParens String
syn region SSSInlineCBraces start=/{/ end=/}/ contains=SSSInlineCBraces contained
hi def link SSSInlineCBraces String
syn match SSSInlineC ;inline C *; nextgroup=SSSInlineCBraces,SSSInlineCParens
hi def link SSSInlineC Keyword
syn region SSSParenGroup start=/(/ end=/)/ contains=@SSSAll,SSSParenGroup contained syn region SSSParenGroup start=/(/ end=/)/ contains=@SSSAll,SSSParenGroup contained
syn match SSSLinkerDirective ;^\s*!link.*$; syn match SSSLinkerDirective ;^\s*!link.*$;
hi SSSLinkerDirective ctermbg=blue ctermfg=black hi SSSLinkerDirective ctermbg=blue ctermfg=black
syn cluster SSSAll contains=SSSVar,SSSComment,SSSChar,SSSString,SSSDSL,SSSExtend,SSSKeyword,SSSOperator, syn cluster SSSAll contains=SSSVar,SSSComment,SSSChar,SSSString,SSSDSL,SSSPath,SSSKeyword,SSSOperator,
\SSSConditional,SSSLoop,SSSFail,SSSStatement,SSSStructure,SSSTypedef,SSSEmptyTable,SSSUse, \SSSConditional,SSSLoop,SSSFail,SSSNull,SSSStatement,SSSStructure,SSSTypedef,SSSEmptyTable,SSSUse,
\SSSNumber,SSSFnDecl,SSSBoolean,SSSNil,SSSTypeAnnotation,SSSAs,SSSDocTest,SSSDocError \SSSNumber,SSSFnDecl,SSSBoolean,SSSNil,SSSDocTest,SSSDocError,SSSArray,SSSTable,
\SSSLinkerDirective \SSSLinkerDirective,SSSInlineC
if !exists('b:current_syntax') if !exists('b:current_syntax')
let b:current_syntax = 'bpeg' let b:current_syntax = 'bpeg'