summaryrefslogtreecommitdiff
path: root/.vim/syntax/cobra.vim
blob: b84158eef2e2f287b58b255d375983fc597900e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
" Vim syntax file
" Language:	Cobra
" Maintainer:
" Updated:	2008-10-11
"
"
" Options to control Cobra syntax highlighting:
"
" For highlighted numbers:
"
"    let cobra_highlight_numbers = 1
"
" For highlighted builtin functions:
"
"    let cobra_highlight_builtins = 1
"
" For highlighted standard exceptions:
"
"    let cobra_highlight_exceptions = 1
"
" Highlight erroneous whitespace:
"
"    let cobra_highlight_space_errors = 1
"
" If you want all possible Cobra highlighting (the same as setting the
" preceding options):
"
"    let cobra_highlight_all = 1
"

" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syn keyword cobraStatement	abstract all any as
syn keyword cobraStatement	assembly assert base be body
syn keyword cobraStatement	bool branch break callable catch
syn keyword cobraStatement	char class continue ct_trace cue
syn keyword cobraStatement	decimal def Dictionary dynamic
syn keyword cobraStatement	ensure enum event expect extend
syn keyword cobraStatement	extern fake false finally float
syn keyword cobraStatement	float32 float64 get
syn keyword cobraStatement	has ignore implements implies
syn keyword cobraStatement	inherits init inlined inout
syn keyword cobraStatement	int int16 int32 int64 int8
syn keyword cobraStatement	interface internal invariant List
syn keyword cobraStatement	listen must namespace new nil
syn keyword cobraStatement	nonvirtual number of off
syn keyword cobraStatement	old on out override
syn keyword cobraStatement	partial pass passthrough print
syn keyword cobraStatement	private pro protected public raise
syn keyword cobraStatement	ref require result return set
syn keyword cobraStatement	Set shared sig stop String
syn keyword cobraStatement	struct success test this throw
syn keyword cobraStatement	to to? trace true try
syn keyword cobraStatement	Type uint uint16 uint32 uint64
syn keyword cobraStatement	uint8 using value var
syn keyword cobraStatement	vari virtual where yield

syn match   cobraFunction	"[a-zA-Z_][a-zA-Z0-9_]*" contained
syn keyword cobraRepeat	for while post
syn keyword cobraConditional	if else
syn keyword cobraOperator	and in is not or
syn keyword cobraPreCondit	use from import
syn match   cobraComment	"#.*$" contains=cobraTodo,@Spell
syn keyword cobraTodo		TODO FIXME XXX contained

" strings
syn region cobraString		matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=cobraEscape,@Spell
syn region cobraString		matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=cobraEscape,@Spell
syn region cobraString		matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=cobraEscape,@Spell
syn region cobraString		matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=cobraEscape,@Spell
syn region cobraRawString	matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+ contains=@Spell
syn region cobraRawString	matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell
syn region cobraRawString	matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+ contains=@Spell
syn region cobraRawString	matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+ contains=@Spell
syn match  cobraEscape		+\\[abfnrtv'"\\]+ contained
syn match  cobraEscape		"\\\o\{1,3}" contained
syn match  cobraEscape		"\\x\x\{2}" contained
syn match  cobraEscape		"\(\\u\x\{4}\|\\U\x\{8}\)" contained
syn match  cobraEscape		"\\$"

if exists("cobra_highlight_all")
  let cobra_highlight_numbers = 1
  let cobra_highlight_builtins = 1
  let cobra_highlight_exceptions = 1
  let cobra_highlight_space_errors = 1
endif

if exists("cobra_highlight_numbers")
  " numbers (including longs and complex)
  syn match   cobraNumber	"\<0x\x\+[Ll]\=\>"
  syn match   cobraNumber	"\<\d\+[LljJ]\=\>"
  syn match   cobraNumber	"\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  syn match   cobraNumber	"\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  syn match   cobraNumber	"\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
endif

if exists("cobra_highlight_builtins")
  " builtin functions, types and objects, not really part of the syntax
  syn keyword cobraBuiltin	True False bool
endif

if exists("cobra_highlight_exceptions")
  " builtin exceptions and warnings
  syn keyword cobraException	Exception
endif

if exists("cobra_highlight_space_errors")
  " trailing whitespace
  syn match   cobraSpaceError   display excludenl "\S\s\+$"ms=s+1
  " mixed tabs and spaces
  syn match   cobraSpaceError   display " \+\t"
  syn match   cobraSpaceError   display "\t\+ "
endif

" This is fast but code inside triple quoted strings screws it up. It
" is impossible to fix because the only way to know if you are inside a
" triple quoted string is to start from the beginning of the file. If
" you have a fast machine you can try uncommenting the "sync minlines"
" and commenting out the rest.
syn sync match cobraSync grouphere NONE "):$"
syn sync maxlines=200
"syn sync minlines=2000

if version >= 508 || !exists("did_cobra_syn_inits")
  if version <= 508
    let did_cobra_syn_inits = 1
    command -nargs=+ HiLink hi link <args>
  else
    command -nargs=+ HiLink hi def link <args>
  endif

  " The default methods for highlighting.  Can be overridden later
  HiLink cobraStatement	Statement
  HiLink cobraFunction		Function
  HiLink cobraConditional	Conditional
  HiLink cobraRepeat		Repeat
  HiLink cobraString		String
  HiLink cobraRawString	String
  HiLink cobraEscape		Special
  HiLink cobraOperator		Operator
  HiLink cobraPreCondit	PreCondit
  HiLink cobraComment		Comment
  HiLink cobraTodo		Todo
  HiLink cobraDecorator	Define
  if exists("cobra_highlight_numbers")
    HiLink cobraNumber	Number
  endif
  if exists("cobra_highlight_builtins")
    HiLink cobraBuiltin	Function
  endif
  if exists("cobra_highlight_exceptions")
    HiLink cobraException	Exception
  endif
  if exists("cobra_highlight_space_errors")
    HiLink cobraSpaceError	Error
  endif

  delcommand HiLink
endif

let b:current_syntax = "cobra"

" vim: ts=8