Updating to the latest syntax (v6) and fixing a few bugs.

This commit is contained in:
Bruce Hill 2019-01-01 17:22:39 -08:00
parent 1f354815b8
commit 3c54954c4d
3 changed files with 42 additions and 30 deletions

View File

@ -11,7 +11,7 @@ setlocal formatoptions-=t
setlocal iskeyword+=$ setlocal iskeyword+=$
setlocal cpoptions+=M setlocal cpoptions+=M
setlocal foldmethod=indent setlocal foldmethod=indent
setlocal formatprg=nomsu\ -t\ format\ - setlocal formatprg=nomsu\ -t\ format\ -q\ -
setlocal expandtab setlocal expandtab
setlocal tabstop=4 setlocal tabstop=4
setlocal shiftwidth=0 setlocal shiftwidth=0

View File

@ -10,7 +10,7 @@ let b:did_indent = 1
setlocal autoindent setlocal autoindent
setlocal indentexpr=GetNomsuIndent() setlocal indentexpr=GetNomsuIndent()
setlocal indentkeys+=0],0" setlocal indentkeys+=0],0),1)
" Only define the function once. " Only define the function once.
if exists("*GetNomsuIndent") if exists("*GetNomsuIndent")
@ -24,12 +24,15 @@ function! GetNomsuIndent()
let previous = getline(previousNum) let previous = getline(previousNum)
let ind = indent(previousNum) let ind = indent(previousNum)
if previous =~ '[{[(:"]\s*$' && previous !~ '^\s*#' "|| previous =~ '^\s*#' " TODO: don't auto-indent inside a multi-line comment?
if previous =~ '\%([{[(:]\|("\)$' && previous !~ '^\s*#'
let ind += &tabstop let ind += &tabstop
endif endif
if line =~ '^\s*[\])}]' " TODO: dedent to matching parens, don't just dedent once
let ind -= &tabstop if line =~ '^\s*\%([\])}]\|")\)'
"let ind -= &tabstop
return current_ind - &tabstop
endif endif
if ind == indent(previousNum) if ind == indent(previousNum)

View File

@ -15,7 +15,7 @@ hi nomsuInterpDelim ctermfg=Gray
"syn region nomsuOneLineComment start=/#/ end=/$/ "syn region nomsuOneLineComment start=/#/ end=/$/
"hi nomsuOneLineComment ctermfg=DarkBlue "hi nomsuOneLineComment ctermfg=DarkBlue
"hi def link nomsuOneLineComment Comment "hi def link nomsuOneLineComment Comment
syn region nomsuComment start=/\(^\z(\s*\)\)\@<=#/ skip=/\n\s*$/ end=/\n\(\z1\s\)\@!/ syn region nomsuComment start=/\%(^\z(\s*\)\)\@<=#/ skip=/\n\s*$/ end=/\n\%(\z1\s\)\@!/
hi nomsuComment ctermfg=DarkBlue hi nomsuComment ctermfg=DarkBlue
hi def link nomsuComment Comment hi def link nomsuComment Comment
@ -28,62 +28,71 @@ hi nomsuDict ctermfg=Green
syn region nomsuParenGroup start=/(/ end=/)/ contains=@nomsuAll syn region nomsuParenGroup start=/(/ end=/)/ contains=@nomsuAll
hi nomsuParenGroup ctermfg=Yellow hi nomsuParenGroup ctermfg=Yellow
syn match nomsuLongTextStart /"$/ contained syn match nomsuTextBackslash /\\\%(\\\|;\)\@=/ nextgroup=nomsuTextEscapedBackslash contained
hi def link nomsuLongTextStart String
syn match nomsuTextBackslash /\\\(\\\)\@=/ nextgroup=nomsuTextEscapedBackslash contained
hi nomsuTextBackslash ctermfg=Gray hi nomsuTextBackslash ctermfg=Gray
syn match nomsuTextEscapedChar /\(\x\{1,3}\|x\x\{1,2}\|.\)/ contained syn match nomsuTextEscapedChar /\%(\\\)\@<=\%(\x\{1,3}\|x\x\{1,2}\|.\)/ contained
hi nomsuTextEscapedChar cterm=bold ctermfg=Blue hi nomsuTextEscapedChar cterm=bold ctermfg=Blue
syn match nomsuTextEscapedBackslash /./ contained syn match nomsuTextEscapedBackslash /./ contained
hi nomsuTextEscapedBackslash cterm=bold ctermfg=Blue hi nomsuTextEscapedBackslash cterm=bold ctermfg=Blue
syn match nomsuTextEscape /\\/ nextgroup=nomsuTextEscapedChar contained syn match nomsuTextEscape /\\\%(\x\{1,3}\|x\x\{1,2}\|.\)/ contains=nomsuTextEscapedChar contained
hi nomsuTextEscape ctermfg=Gray hi nomsuTextEscape ctermfg=Gray
syn match nomsuInterp /\\\([[{($:]\)\@=/ nextgroup=nomsuVar,nomsuList,nomsuDict,nomsuParenGroup,nomsuIndentedBlock contained syn match nomsuInterp /\\\%([[{($:]\)\@=/ nextgroup=nomsuVar,nomsuList,nomsuDict,nomsuParenGroup,nomsuIndentedInterpBlock contained
hi nomsuInterp ctermfg=Gray hi nomsuInterp ctermfg=Gray
syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\\s*$/ end=/\.\./ contained syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\\s*$/ end=/\.\./ contained
hi nomsuInterpDotDot ctermfg=Gray hi nomsuInterpDotDot ctermfg=Gray
syn region nomsuLongTextValue start=/^/ end=/$/ contained syn region nomsuIndentedText matchgroup=nomsuTextQuotes start=/\%(^\z(\(\s*\)\)[^\n]*\)\@<=("$/ end=/^\z1")/
\ contains=nomsuInterp,nomsuInterpDotDot,nomsuTextBackslash \ contains=nomsuInterp,nomsuInterpDotDot,nomsuTextBackslash
hi def link nomsuLongTextValue String hi def link nomsuIndentedText String
syn region nomsuLongText start=/\(^\z(\s*\)[^\n]*\)\@<="$/ skip=/\n\s*$/ end=/\n\(\z1\s\)\@!"\?/ hi nomsuTextQuotes ctermfg=DarkMagenta
\ contains=nomsuLongTextStart,nomsuLongTextValue
syn region nomsuText start=/"\($\)\@!/ skip=/\\./ end=/"/ contains=nomsuInterp,nomsuTextEscape syn region nomsuText matchgroup=nomsuTextQuotes start=/"\%($\)\@!/ end=/"/ contains=nomsuInterp,nomsuTextEscape
hi def link nomsuText String hi def link nomsuText String
syn region nomsuIndentedBlock start=/\(^\z(\s*\)[^\n]*\)\@<=:\s*$/ skip=/\n\s*$/ end=/\n\(\z1\s\)\@!\(\s*\.\.\)\?/ syn region nomsuIndentedBlock start=/\%(^\z(\s*\)[^\n]*\)\@<=:\s*$/ end=/\n\%(\z1\s\)\@!\%(\s*\.\.\)\?/
\ contains=@nomsuAll
syn region nomsuIndentedInterpBlock matchgroup=nomsuColon start=/:\s*$/ end=/\n\s*\.\./ contained
\ contains=@nomsuAll \ contains=@nomsuAll
syn match nomsuVar /\$\((\([ a-zA-Z0-9_`~!@^&*_+=|<>?'/-]\|[^\x00-\xff]\)\+)\|\([a-zA-Z0-9_-]\|[^\x00-\xff]\)\+\)\?/ syn match nomsuVar /\$\%(\%([a-zA-Z0-9_-]\|[^\x00-\xff]\)\+\|(\@!\)/
\ contains=nomsuDollarSign,nomsuVarParens \ contains=nomsuDollarSign,nomsuVarParens
hi nomsuVar ctermfg=Cyan hi nomsuVar ctermfg=Cyan
hi def link nomsuVar Identifier hi def link nomsuVar Identifier
syn region nomsuActionVar matchgroup=nomsuVar start=/\$(/ end=/)/ contains=nomsuVarWord,nomsuVarWord,@nomsuAll
syn match nomsuDollarSign /\$/ contained syn match nomsuDollarSign /\$/ contained
hi nomsuDollarSign ctermfg=Cyan hi nomsuDollarSign ctermfg=Cyan
syn match nomsuVarParens /[()]/ contained syn match nomsuVarParens /[()]/ contained
hi nomsuVarParens ctermfg=LightCyan hi nomsuVarParens ctermfg=LightCyan
syn match nomsuWord /\([a-zA-Z_]\|[^\x00-\xff]\)\([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ syn match nomsuWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/
hi def link nomsuWord Function hi def link nomsuWord Function
hi nomsuWord ctermfg=White hi nomsuWord ctermfg=White
syn match nomsuOpWord ;[`~!@^&*_+=<>?'/-]\+\|\(^\s*\)\@<!#; syn match nomsuOpWord ;[`~!@^&*_+=<>?'/-]\+\|\%(^\s*\)\@<!#;
hi def link nomsuOpWord Function hi def link nomsuOpWord Function
hi nomsuOpWord ctermfg=LightYellow hi nomsuOpWord ctermfg=LightYellow
syn match nomsuNumber /-\?\(0x\x\+\|\d\+\(\.\(\d\+\)\?\)\?\|\.\d\+\)/ syn match nomsuVarWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained
hi def link nomsuVarWord Function
hi nomsuVarWord ctermfg=Cyan
syn match nomsuVarOpWord ;[`~!@^&*_+=<>?'/-]\+\|\%(^\s*\)\@<!#; contained
hi def link nomsuVarOpWord Function
hi nomsuVarOpWord ctermfg=Cyan
syn match nomsuNumber /-\?\%(0x\x\+\|\d\+\%(\.\%(\d\+\)\?\)\?\|\.\d\+\)/
hi def link nomsuNumber Number hi def link nomsuNumber Number
hi nomsuNumber ctermfg=Red hi nomsuNumber ctermfg=Red
syn match nomsuInt /-\?\(0x\x\+\|\d\+\)/ syn match nomsuInt /-\?\%(0x\x\+\|\d\+\)/
hi def link nomsuInt Number hi def link nomsuInt Number
hi nomsuInt ctermfg=Red hi nomsuInt ctermfg=Red
syn match nomsuTextWord /\([a-zA-Z_]\|[^\x00-\xff]\)\([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained syn match nomsuTextWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained
hi def link nomsuTextWord String hi def link nomsuTextWord String
syn match nomsuIndex /\./ nextgroup=nomsuTextWord,@nomsuExpr syn match nomsuIndex /\./ nextgroup=nomsuTextWord,nomsuParenGroup,nomsuText,nomsuIndentedText,
\nomsuVar,nomsuActionVar,nomsuInt,nomsuDict,nomsuList,nomsuIndentedBlock
hi nomsuIndex ctermfg=Yellow hi nomsuIndex ctermfg=Yellow
syn match nomsuDotDot /\.\./ syn match nomsuDotDot /\.\./
@ -102,12 +111,12 @@ syn match nomsuSemicolon /;/
hi nomsuSemicolon ctermfg=Blue hi nomsuSemicolon ctermfg=Blue
hi def link nomsuSemicolon Delimiter hi def link nomsuSemicolon Delimiter
syn cluster nomsuExpr contains=nomsuParenGroup,nomsuText,nomsuLongText,nomsuVar,nomsuNumber, syn cluster nomsuExpr contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuVar,
\ nomsuDict,nomsuList,nomsuIndentedBlock \nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock
syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuLongText,nomsuComment, syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuComment,
\ nomsuVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock,nomsuColon,nomsuSemicolon, \ nomsuVar,nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock,
\ nomsuDotDot,nomsuWord,nomsuOpWord,nomsuComma,nomsuIndex \ nomsuColon,nomsuSemicolon,nomsuDotDot,nomsuWord,nomsuOpWord,nomsuComma,nomsuIndex
if !exists('b:current_syntax') if !exists('b:current_syntax')
let b:current_syntax = 'nomsu' let b:current_syntax = 'nomsu'