Updating to the latest syntax (v6) and fixing a few bugs.
This commit is contained in:
parent
1f354815b8
commit
3c54954c4d
@ -11,7 +11,7 @@ setlocal formatoptions-=t
|
||||
setlocal iskeyword+=$
|
||||
setlocal cpoptions+=M
|
||||
setlocal foldmethod=indent
|
||||
setlocal formatprg=nomsu\ -t\ format\ -
|
||||
setlocal formatprg=nomsu\ -t\ format\ -q\ -
|
||||
setlocal expandtab
|
||||
setlocal tabstop=4
|
||||
setlocal shiftwidth=0
|
||||
|
@ -10,7 +10,7 @@ let b:did_indent = 1
|
||||
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetNomsuIndent()
|
||||
setlocal indentkeys+=0],0"
|
||||
setlocal indentkeys+=0],0),1)
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetNomsuIndent")
|
||||
@ -24,12 +24,15 @@ function! GetNomsuIndent()
|
||||
let previous = getline(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
|
||||
endif
|
||||
|
||||
if line =~ '^\s*[\])}]'
|
||||
let ind -= &tabstop
|
||||
" TODO: dedent to matching parens, don't just dedent once
|
||||
if line =~ '^\s*\%([\])}]\|")\)'
|
||||
"let ind -= &tabstop
|
||||
return current_ind - &tabstop
|
||||
endif
|
||||
|
||||
if ind == indent(previousNum)
|
||||
|
@ -15,7 +15,7 @@ hi nomsuInterpDelim ctermfg=Gray
|
||||
"syn region nomsuOneLineComment start=/#/ end=/$/
|
||||
"hi nomsuOneLineComment ctermfg=DarkBlue
|
||||
"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 def link nomsuComment Comment
|
||||
|
||||
@ -28,62 +28,71 @@ hi nomsuDict ctermfg=Green
|
||||
syn region nomsuParenGroup start=/(/ end=/)/ contains=@nomsuAll
|
||||
hi nomsuParenGroup ctermfg=Yellow
|
||||
|
||||
syn match nomsuLongTextStart /"$/ contained
|
||||
hi def link nomsuLongTextStart String
|
||||
syn match nomsuTextBackslash /\\\(\\\)\@=/ nextgroup=nomsuTextEscapedBackslash contained
|
||||
syn match nomsuTextBackslash /\\\%(\\\|;\)\@=/ nextgroup=nomsuTextEscapedBackslash contained
|
||||
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
|
||||
syn match nomsuTextEscapedBackslash /./ contained
|
||||
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
|
||||
syn match nomsuInterp /\\\([[{($:]\)\@=/ nextgroup=nomsuVar,nomsuList,nomsuDict,nomsuParenGroup,nomsuIndentedBlock contained
|
||||
syn match nomsuInterp /\\\%([[{($:]\)\@=/ nextgroup=nomsuVar,nomsuList,nomsuDict,nomsuParenGroup,nomsuIndentedInterpBlock contained
|
||||
hi nomsuInterp ctermfg=Gray
|
||||
syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\\s*$/ end=/\.\./ contained
|
||||
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
|
||||
hi def link nomsuLongTextValue String
|
||||
syn region nomsuLongText start=/\(^\z(\s*\)[^\n]*\)\@<="$/ skip=/\n\s*$/ end=/\n\(\z1\s\)\@!"\?/
|
||||
\ contains=nomsuLongTextStart,nomsuLongTextValue
|
||||
hi def link nomsuIndentedText String
|
||||
hi nomsuTextQuotes ctermfg=DarkMagenta
|
||||
|
||||
syn region nomsuText start=/"\($\)\@!/ skip=/\\./ end=/"/ contains=nomsuInterp,nomsuTextEscape
|
||||
syn region nomsuText matchgroup=nomsuTextQuotes start=/"\%($\)\@!/ end=/"/ contains=nomsuInterp,nomsuTextEscape
|
||||
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
|
||||
|
||||
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
|
||||
hi nomsuVar ctermfg=Cyan
|
||||
hi def link nomsuVar Identifier
|
||||
|
||||
syn region nomsuActionVar matchgroup=nomsuVar start=/\$(/ end=/)/ contains=nomsuVarWord,nomsuVarWord,@nomsuAll
|
||||
|
||||
syn match nomsuDollarSign /\$/ contained
|
||||
hi nomsuDollarSign ctermfg=Cyan
|
||||
|
||||
syn match nomsuVarParens /[()]/ contained
|
||||
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 nomsuWord ctermfg=White
|
||||
syn match nomsuOpWord ;[`~!@^&*_+=<>?'/-]\+\|\(^\s*\)\@<!#;
|
||||
syn match nomsuOpWord ;[`~!@^&*_+=<>?'/-]\+\|\%(^\s*\)\@<!#;
|
||||
hi def link nomsuOpWord Function
|
||||
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 nomsuNumber ctermfg=Red
|
||||
|
||||
syn match nomsuInt /-\?\(0x\x\+\|\d\+\)/
|
||||
syn match nomsuInt /-\?\%(0x\x\+\|\d\+\)/
|
||||
hi def link nomsuInt Number
|
||||
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
|
||||
|
||||
syn match nomsuIndex /\./ nextgroup=nomsuTextWord,@nomsuExpr
|
||||
syn match nomsuIndex /\./ nextgroup=nomsuTextWord,nomsuParenGroup,nomsuText,nomsuIndentedText,
|
||||
\nomsuVar,nomsuActionVar,nomsuInt,nomsuDict,nomsuList,nomsuIndentedBlock
|
||||
hi nomsuIndex ctermfg=Yellow
|
||||
|
||||
syn match nomsuDotDot /\.\./
|
||||
@ -102,12 +111,12 @@ syn match nomsuSemicolon /;/
|
||||
hi nomsuSemicolon ctermfg=Blue
|
||||
hi def link nomsuSemicolon Delimiter
|
||||
|
||||
syn cluster nomsuExpr contains=nomsuParenGroup,nomsuText,nomsuLongText,nomsuVar,nomsuNumber,
|
||||
\ nomsuDict,nomsuList,nomsuIndentedBlock
|
||||
syn cluster nomsuExpr contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuVar,
|
||||
\nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock
|
||||
|
||||
syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuLongText,nomsuComment,
|
||||
\ nomsuVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock,nomsuColon,nomsuSemicolon,
|
||||
\ nomsuDotDot,nomsuWord,nomsuOpWord,nomsuComma,nomsuIndex
|
||||
syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuComment,
|
||||
\ nomsuVar,nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock,
|
||||
\ nomsuColon,nomsuSemicolon,nomsuDotDot,nomsuWord,nomsuOpWord,nomsuComma,nomsuIndex
|
||||
|
||||
if !exists('b:current_syntax')
|
||||
let b:current_syntax = 'nomsu'
|
||||
|
Loading…
Reference in New Issue
Block a user