vim-nomsu/syntax/nomsu.vim
2017-10-20 14:33:24 -07:00

82 lines
3.0 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 match nomsuLongStringStart /"\.\."/ contains=nomsuIndentor contained
hi nomsuLongStringStart ctermfg=Yellow
syn match nomsuStringPipe /|/ contained
hi nomsuStringPipe ctermfg=DarkGray
syn match nomsuStringBackslash /\\\\/ contained
hi nomsuStringBackslash ctermbg=Black ctermfg=Blue
syn match nomsuStringEscapedQuote /\\"/ contained
hi nomsuStringEscapedQuote ctermbg=Black ctermfg=Blue
hi def link nomsuStringPipe Special
syn region nomsuInterp matchgroup=nomsuInterpDelim start=/\\(/ end=/)/ contained
\ contains=@nomsuAll
syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\$/ end=/\.\./ contained
syn region nomsuLongStringValue start=/\(|\)\@<=/ end=/$/ contained
\ contains=nomsuInterp,nomsuInterpDotDot,nomsuStringBackslash
hi nomsuLongStringValue ctermbg=Black ctermfg=Gray
hi def link nomsuLongStringValue String
syn region nomsuLongStringLine start=/^\s\+|/ end=/\n/ contained
\ contains=nomsuStringPipe,nomsuLongStringValue
syn region nomsuLongString start=/\(^\z(\s*\)[^\n]*\)\@<="\.\."/ skip=/^\s*$/ end=/^\(\z1\s\)\@!/
\ contains=nomsuLongStringStart,nomsuOneLineComment,nomsuComment,nomsuLongStringLine
syn region nomsuString start=/\("\.\.\)\@<!"\(\.\."\)\@!/ skip=/\\\\\|\\"/ end=/$\|"/
\ contains=nomsuInterp,nomsuStringBackslash,nomsuStringEscapedQuote
hi nomsuString ctermbg=Black ctermfg=Gray
hi def link nomsuString String
syn match nomsuVar /%\([a-zA-Z0-9_]*\|[`$~!@^&*_+=|<>?-]*\)\?/
hi nomsuVar ctermfg=Cyan
hi def link nomsuVar Identifier
syn match nomsuWord /\v[a-zA-Z0-9_]+/
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\+\)\?\)\?/
syn match nomsuNumber /-\?\.\d\+/
hi def link nomsuNumber Number
syn match nomsuDotDot /\.\./
hi def link nomsuDotDot Special
hi nomsuDotDot ctermfg=DarkGray
syn match nomsuDelim /[,;()\[\]]/
hi nomsuDelim ctermfg=Yellow
hi def link nomsuDelim Delimiter
syn match nomsuThunk /:/
hi nomsuThunk ctermfg=Yellow
hi def link nomsuThunk Structure
syn cluster nomsuAll contains=nomsuString,nomsuLongString,nomsuComment,nomsuOneLineComment,
\ nomsuVar,nomsuNumber,nomsuDelim,nomsuThunk,nomsuDotDot,nomsuWord,nomsuOpWord
if !exists('b:current_syntax')
let b:current_syntax = 'nomsu'
endif