vim-nomsu/syntax/nomsu.vim

93 lines
3.5 KiB
VimL

" Language: Nomsu
" Maintainer: Bruce Hill <bruce@bruce-hill.com>
" License: WTFPL
" Bail if our syntax is already loaded.
if exists('b:current_syntax') && b:current_syntax == 'nomsu'
finish
endif
" Highlight long strings.
syn sync minlines=100
hi def link nomsuInterpDelim PreProc
syn region nomsuOneLineComment start=/#/ end=/$/
hi nomsuOneLineComment ctermfg=DarkBlue
hi def link nomsuOneLineComment Comment
syn region nomsuComment start=/\(^\z(\s*\)[^\n]*\)\@<=#/ skip=/\n\s*$/ end=/\n\(\z1\s\)\@!/
hi nomsuComment ctermfg=DarkBlue
hi def link nomsuComment Comment
syn region nomsuList start=/\[/ end=/$\|\]/ contains=@nomsuAll,nomsuComma nextgroup=nomsuIndex
hi nomsuList ctermfg=Blue
syn region nomsuDict start=/{/ end=/$\|}/ contains=nomsuColon,nomsuComma,@nomsuAll nextgroup=nomsuIndex
hi nomsuDict ctermfg=Green
syn region nomsuParenGroup start=/(/ end=/$\|)/ contains=@nomsuAll nextgroup=nomsuIndex
hi nomsuParenGroup ctermfg=Yellow
syn match nomsuLongTextStart /"\.\."/ contains=nomsuDotDot contained
hi def link nomsuLongTextStart String
syn match nomsuTextBackslash /\\\\/ contained
hi nomsuTextBackslash ctermfg=Blue
syn match nomsuTextEscapedQuote /\\"/ contained
hi nomsuTextEscapedQuote ctermfg=Blue
syn match nomsuInterp /\\\([%[{"(]\)\@=/ nextgroup=nomsuVar,nomsuText,nomsuList,nomsuDict,nomsuParenGroup contained
hi nomsuInterp ctermfg=Gray
syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\$/ end=/\.\./ contained
syn region nomsuLongTextValue start=/^/ end=/$/ contained
\ contains=nomsuInterp,nomsuInterpDotDot,nomsuTextBackslash
hi def link nomsuLongTextValue String
syn region nomsuLongText start=/\(^\z(\s*\)[^\n]*\)\@<="\.\."/ skip=/^\s*$/ end=/^\(\z1\s\)\@!/
\ contains=nomsuLongTextStart,nomsuLongTextValue
syn region nomsuText start=/\("\.\.\)\@<!"\(\.\."\)\@!/ skip=/\\\\\|\\"/ end=/$\|"/ nextgroup=nomsuIndex
\ contains=nomsuInterp,nomsuTextBackslash,nomsuTextEscapedQuote
hi def link nomsuText String
syn match nomsuTextWord /\([a-zA-Z_]\|[^\x00-\xff]\)\([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained nextgroup=nomsuIndex
hi def link nomsuTextWord String
syn match nomsuVar /%\([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ nextgroup=nomsuIndex
hi nomsuVar ctermfg=Cyan
hi def link nomsuVar Identifier
syn match nomsuIndex /\./ nextgroup=nomsuVar,nomsuNumber,nomsuParenGroup,nomsuText,nomsuList,nomsuDict,nomsuTextWord
hi nomsuIndex ctermfg=Yellow
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 ;\v[`$~!@^&*_+=|<>?'/-]+;
hi def link nomsuOpWord Function
hi nomsuOpWord ctermfg=LightYellow
syn match nomsuNumber /-\?\d\+\(\.\(\d\+\)\?\)\?/ nextgroup=nomsuIndex
syn match nomsuNumber /-\?\.\d\+/ nextgroup=nomsuIndex
hi def link nomsuNumber Number
syn match nomsuDotDot /\.\./
hi def link nomsuDotDot Special
hi nomsuDotDot ctermfg=DarkGray
syn match nomsuComma /,/
hi nomsuComma ctermfg=Blue
hi def link nomsuComma Delimiter
syn match nomsuColon /:/
hi nomsuColon ctermfg=Yellow
hi def link nomsuColon Delimiter
syn match nomsuSemicolon /;/
hi nomsuSemicolon ctermfg=Blue
hi def link nomsuSemicolon Delimiter
syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuLongText,nomsuComment,nomsuOneLineComment,
\ nomsuVar,nomsuNumber,nomsuDict,nomsuList,nomsuColon,nomsuSemicolon,
\ nomsuDotDot,nomsuWord,nomsuOpWord
if !exists('b:current_syntax')
let b:current_syntax = 'nomsu'
endif