code / vim-nomsu

Lines141 vim script136 Markdown5
(125 lines)
1 " Language: Nomsu
2 " Maintainer: Bruce Hill <bruce@bruce-hill.com>
3 " License: WTFPL
5 " Bail if our syntax is already loaded.
6 if exists('b:current_syntax') && b:current_syntax == 'nomsu'
7 finish
8 endif
10 " Highlight long strings.
11 syn sync minlines=100
13 "hi def link nomsuInterpDelim PreProc
14 hi nomsuInterpDelim ctermfg=Gray
15 syn region nomsuLineComment start=;//; end=/$/
16 hi nomsuLineComment ctermfg=DarkBlue
17 hi def link nomsuLineComment Comment
19 syn region nomsuList start=/\[/ end=/\]/ contains=@nomsuAll
20 hi nomsuList ctermfg=Blue
22 syn region nomsuDict start=/{/ end=/}/ contains=@nomsuAll
23 hi nomsuDict ctermfg=Green
25 syn region nomsuParenGroup start=/(/ end=/)/ contains=@nomsuAll
26 hi nomsuParenGroup ctermfg=Yellow
28 syn match nomsuTextBackslash /\\\%(\\\|;\)\@=/ nextgroup=nomsuTextEscapedBackslash contained
29 hi nomsuTextBackslash ctermfg=Gray
30 syn match nomsuTextEscapedChar /\%(\\\)\@<=\%(\x\{1,3}\|x\x\{1,2}\|.\)/ contained
31 hi nomsuTextEscapedChar cterm=bold ctermfg=Blue
32 syn match nomsuTextEscapedBackslash /./ contained
33 hi nomsuTextEscapedBackslash cterm=bold ctermfg=Blue
34 syn match nomsuTextEscape /\\\%(\x\{1,3}\|x\x\{1,2}\|.\)/ contains=nomsuTextEscapedChar contained
35 hi nomsuTextEscape ctermfg=Gray
36 syn match nomsuInterp /\\\%([[{($:]\)\@=/
37 \ nextgroup=nomsuActionVar,nomsuVar,nomsuList,nomsuDict,nomsuParenGroup,nomsuIndentedInterpBlock contained
38 hi nomsuInterp ctermfg=Gray
39 syn region nomsuInterpDotDot matchgroup=nomsuInterpDelim start=/\\\s*$/ end=/\.\./ contained
40 hi nomsuInterpDotDot ctermfg=Gray
41 syn region nomsuIndentedText matchgroup=nomsuTextQuotes start=/\%(^\z(\(\s*\)\)[^\n]*\)\@<=("$/ end=/^\z1")/
42 \ contains=nomsuInterp,nomsuInterpDotDot,nomsuTextBackslash
43 hi def link nomsuIndentedText String
44 hi nomsuTextQuotes ctermfg=DarkMagenta
46 syn region nomsuText matchgroup=nomsuTextQuotes start=/\%((\)\@<!"\|"\%($\)\@!/ end=/"\|$/ contains=nomsuInterp,nomsuTextEscape
47 hi def link nomsuText String
49 syn region nomsuIndentedBlock start=/\%(^\z(\s*\)[^\n]*\)\@<=:\s*$/ end=/\n\%(\z1\s\)\@!\%(\s*\.\.\)\?/
50 \ contains=@nomsuAll
51 syn region nomsuIndentedInterpBlock matchgroup=nomsuColon start=/:\s*$/ end=/\n\s*\.\./ contained
52 \ contains=@nomsuAll
54 syn match nomsuVar /\$\%(\%([a-zA-Z0-9_-]\|[^\x00-\xff]\)\+\|(\@!\)/
55 \ contains=nomsuDollarSign,nomsuVarParens
56 hi nomsuVar ctermfg=Cyan
57 hi def link nomsuVar Identifier
59 syn region nomsuActionVar matchgroup=nomsuVar start=/\$(/ end=/)\|$/ contains=nomsuVarWord,nomsuVarOpWord,@nomsuAll
61 syn match nomsuDollarSign /\$/ contained
62 hi nomsuDollarSign ctermfg=Cyan
64 syn match nomsuVarParens /[()]/ contained
65 hi nomsuVarParens ctermfg=LightCyan
67 syn match nomsuWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/
68 hi def link nomsuWord Function
69 hi nomsuWord ctermfg=White
70 syn match nomsuOpWord ;\(\(//\)\@![`~!|%#@^&*_+=<>?'/-]\)\+\|\%(^\s*\)\@<!#;
71 hi def link nomsuOpWord Function
72 hi nomsuOpWord ctermfg=LightYellow
74 syn match nomsuVarWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained
75 hi def link nomsuVarWord Function
76 hi nomsuVarWord ctermfg=LightCyan
77 syn match nomsuVarOpWord ;\(\(//\)\@![`~!|%#@^&*_+=<>?'/-]\)\+\|\%(^\s*\)\@<!#; contained
78 hi def link nomsuVarOpWord Function
79 hi nomsuVarOpWord ctermfg=LightCyan
81 syn match nomsuNumber /-\?\%(0x\x\+\|\d\+\%(\.\%(\d\+\)\?\)\?\|\.\d\+\)/
82 hi def link nomsuNumber Number
83 hi nomsuNumber ctermfg=Red
85 syn match nomsuInt /-\?\%(0x\x\+\|\d\+\)/
86 hi def link nomsuInt Number
87 hi nomsuInt ctermfg=Red
89 syn match nomsuTextWord /\%([a-zA-Z_]\|[^\x00-\xff]\)\%([a-zA-Z0-9_]\|[^\x00-\xff]\)*/ contained
90 hi def link nomsuTextWord String
92 syn match nomsuIndex /\./ nextgroup=nomsuTextWord,nomsuParenGroup,nomsuText,nomsuIndentedText,
93 \nomsuVar,nomsuActionVar,nomsuInt,nomsuDict,nomsuList,nomsuIndentedBlock
94 hi nomsuIndex ctermfg=Yellow
96 syn match nomsuDotDot /\.\./
97 hi def link nomsuDotDot Special
98 hi nomsuDotDot ctermfg=DarkGray
100 syn match nomsuComma /,/
101 hi nomsuComma ctermfg=Blue
102 hi def link nomsuComma Delimiter
104 syn match nomsuColon /:/
105 hi nomsuColon ctermfg=Yellow
106 hi def link nomsuColon Delimiter
108 syn match nomsuSemicolon /;/
109 hi nomsuSemicolon ctermfg=Blue
110 hi def link nomsuSemicolon Delimiter
112 syn region nomsuComment start=/\%(^\z(\s*\)\)\@<=#/ skip=/\n\s*$/ end=/\n\%(\z1\s\)\@!/
113 hi nomsuComment ctermfg=DarkBlue
114 hi def link nomsuComment Comment
116 syn cluster nomsuExpr contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuVar,
117 \nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock
119 syn cluster nomsuAll contains=nomsuParenGroup,nomsuText,nomsuIndentedText,nomsuComment,nomsuLineComment,
120 \ nomsuVar,nomsuActionVar,nomsuNumber,nomsuDict,nomsuList,nomsuIndentedBlock,
121 \ nomsuColon,nomsuSemicolon,nomsuDotDot,nomsuWord,nomsuOpWord,nomsuComma,nomsuIndex
123 if !exists('b:current_syntax')
124 let b:current_syntax = 'nomsu'
125 endif