]> granicus.if.org Git - icinga2/blob - tools/syntax/vim/syntax/icinga2.vim
833b33e0b67a958d7c8d2b534f183f7ab87b2d65
[icinga2] / tools / syntax / vim / syntax / icinga2.vim
1 " Vim syntax file
2 " Filename:             icinga2.vim
3 " Language:             Icinga2 object configuration file
4 " Author:               Carlos Cesario <carloscesario@gmail.com>
5 " Version:              0.0.2
6 " Based:                javascript.vim / nagios.vim
7
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
10 if !exists("main_syntax")
11         if version < 600
12                 syntax clear
13         elseif exists("b:current_syntax")
14                 finish
15         endif
16         let main_syntax = 'icinga2'
17 endif
18
19
20 " case off
21 syntax case ignore
22
23 " comments
24 syn keyword             icinga2CommentTodo              TODO FIXME XXX TBD contained
25 syn match               icinga2LineComment              "\/\/.*" contains=icinga2CommentTodo
26 syn match               icinga2CommentSkip              "^[ \t]*\*\($\|[ \t]\+\)"
27 syn region              icinga2Comment                  start="/\*"  end="\*/" contains=icinga2CommentTodo
28
29 " type definitions
30 " - double quotes "
31 " - single quotes '
32 " - brackets <>
33
34 syn region              StringD                 start=+"+  end=+"\|$+
35 syn region              StringS                 start=+'+  end=+'\|$+
36 syn match               angleBrackets   "<\w\+>"
37
38
39 " Braces and Parens definition
40 " Braces are used in dictionary definition
41
42 syn match               Braces          "[{}\[\]]"
43 syn match               Parens          "[()]"
44
45
46 " objects types
47 syn match               icinga2ObjDef           "object[ \t]\+\(hostgroup\|host\|service\|servicegroup\|user\|usergroup\)"
48 syn match               icinga2ObjDef           "object[ \t]\+\(checkcommand\|notificationcommand\|eventcommand\|notification\)"
49 syn match               icinga2Objdef           "object[ \t]\+\(timeperiod\|scheduleddowntime\|dependency\|perfdatawriter\)"
50 syn match               icinga2ObjDef           "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)"
51 syn match               icinga2ObjDef           "object[ \t]\+\(livestatuslistener\|statusdatawriter\|externalcommandlistener\)"
52 syn match               icinga2ObjDef           "object[ \t]\+\(compatlogger\|checkresultreader\|checkcomponent\|notificationcomponent\)"
53 syn match               icinga2ObjDef           "object[ \t]\+\(filelogger\|sysloglogger\|icingastatuswriter\|apilistener\|endpoint\|zone\)"
54
55
56 " apply def
57 syn match               icinga2ApplyDef         "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)"
58
59
60 " objects attributes
61 syn keyword             icinga2ObjAttr          contained       accept_commands accept_config action_url address address6 arguments author bind_host
62 syn keyword             icinga2ObjAttr          contained       bind_port ca_path categories cert_path check_command check_interval
63 syn keyword             icinga2ObjAttr          contained       check_period child_host_name child_service_name cleanup command command_endpoint command_path
64 syn keyword             icinga2ObjAttr          contained       comment compat_log_path crl_path database disable_checks disable_notifications
65 syn keyword             icinga2ObjAttr          contained       display_name duration email enable_active_checks enable_event_handler
66 syn keyword             icinga2ObjAttr          contained       enable_flapping enable_ha enable_notifications enable_passive_checks enable_perfdata
67 syn keyword             icinga2ObjAttr          contained       endpoints env event_command failover_timeout fixed flapping_threshold groups host
68 syn keyword             icinga2ObjAttr          contained       host_format_template host_name host_name_template host_perfdata_path host_temp_path icon_image
69 syn keyword             icinga2ObjAttr          contained       icon_image_alt instance_description instance_name interval key_path log_dir
70 syn keyword             icinga2ObjAttr          contained       log_duration max_check_attempts methods name notes notes_url objects_path
71 syn keyword             icinga2ObjAttr          contained       pager parent parent_host_name parent_service_name password path period
72 syn keyword             icinga2ObjAttr          contained       port ranges retry_interval rotation_interval rotation_method
73 syn keyword             icinga2ObjAttr          contained       service_format_template service_name service_name_template service_perfdata_path service_temp_path
74 syn keyword             icinga2ObjAttr          contained       severity socket_path socket_type spool_dir states status_path table_prefix
75 syn keyword             icinga2ObjAttr          contained       timeout times types update_interval user user_groups users volatile zone
76 syn match               icinga2ObjAttr          contained       "\(vars.\w\+\)"
77
78
79 " keywords
80 syn keyword             icinga2Keyword          template const import include include_recursive var function
81
82
83 " Assign conditions
84 syn match               icinga2AssingCond       contained       "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)"
85
86
87 " Global functions
88 syn keyword             icinga2GFunction        contained       regex match len union intersection keys string
89 syn keyword     icinga2GFunction        contained       number bool random log typeof get_time exit
90
91
92 " Accessor Functions
93 syn keyword     icinga2AFunction        contained       get_host get_service get_user get_check_command get_event_command get_notification_command
94 syn keyword     icinga2AFunction        contained       get_host_group get_service_group get_user_group get_time_period
95
96
97 " Math functions
98 syn match       icinga2MathFunction     contained       "\(Math.E\|Math.LN2\|Math.LN10\|Math.LOG2E\|Math.PI\|Math.SQRT1_2\|Math.SQRT2\)"
99 syn match       icinga2MathFunction     contained       "\(Math.abs\|Math.acos\|Math.asin\|Math.atan\|Math.atan2\|Math.ceil\|Math.cos\)"
100 syn match       icinga2MathFunction     contained       "\(Math.exp\|Math.floor\|Math.isinf\|Math.isnan\|Math.log\|Math.max\|Math.min\)"
101 syn match       icinga2MathFunction     contained       "\(Math.pow\|Math.random\|Math.round\|Math.sign\|Math.sin\|Math.sqrt\|Math.tan\)"
102
103 " Json functions
104 syn match       icinga2JsonFunction             contained       "\(Json.encode\|Json.decode\)"
105
106 " String functions
107 syn match       icinga2StrFunction      contained       "\(\.to_string\)"
108 syn match       icinga2StrFunction      contained       "\(\.find\)"
109 syn match       icinga2StrFunction      contained       "\(\.contains\)"
110 syn match       icinga2StrFunction      contained       "\(\.len\)"
111 syn match       icinga2StrFunction      contained       "\(\.lower\)"
112 syn match       icinga2StrFunction      contained       "\(\.upper\)"
113 syn match       icinga2StrFunction      contained       "\(\.replace\)"
114 syn match       icinga2StrFunction      contained       "\(\.split\)"
115 syn match       icinga2StrFunction      contained       "\(\.substr\)"
116
117 " Array and Dict  Functions
118 syn match       icinga2ArrFunction      contained       "\(\.add\)"
119 syn match       icinga2ArrFunction      contained       "\(\.clear\)"
120 syn match       icinga2ArrFunction      contained       "\(\.clone\)"
121 syn match       icinga2ArrFunction      contained       "\(\.contains\)"
122 syn match       icinga2ArrFunction      contained       "\(\.len\)"
123 syn match       icinga2ArrFunction      contained       "\(\.remove\)"
124 syn match       icinga2ArrFunction      contained       "\(\.set\)"
125 syn match       icinga2ArrFunction      contained       "\(\.remove\)"
126 syn match       icinga2ArrFunction      contained       "\(\.sort\)"
127 syn match       icinga2ArrFunction      contained       "\(\.join\)"
128 syn match       icinga2ArrFunction      contained       "\(\.clone\)"
129 syn match       icinga2ArrFunction      contained       "\(\.call\)"
130 syn match       icinga2ArrFunction      contained       "\(\.callv\)"
131
132
133 " Conditional statements
134 syn keyword     icinga2Cond                     if else
135
136 " Loops
137 syn keyword     icinga2Loop                     while for break continue
138
139 " Operators
140 syn  match         icinga2Operators "[ \t]\+\(\.\)\+"
141 syn  match         icinga2Operators "[ \t]\+\(!\)\+"
142 syn  match         icinga2Operators "[ \t]\+\(\~\)\+"
143 syn  match         icinga2Operators "[ \t]\+\(+\)\+"
144 syn  match         icinga2Operators "[ \t]\+\(-\)\+"
145 syn  match         icinga2Operators "[ \t]\+\(*\)\+"
146 syn  match         icinga2Operators "[ \t]\+\(/\)\+"
147 syn  match         icinga2Operators "[ \t]\+\(%\)\+"
148 syn  match         icinga2Operators "[ \t]\+\(+\)\+"
149 syn  match         icinga2Operators "[ \t]\+\(-\)\+"
150 syn  match         icinga2Operators "[ \t]\+\(=\)\+"
151 syn  match         icinga2Operators "[ \t]\+\(<\)[ \t]\+"
152 syn  match         icinga2Operators "[ \t]\+\(>\)[ \t]\+"
153 syn  match         icinga2Operators "[ \t]\+\(<<\)\+"
154 syn  match         icinga2Operators "[ \t]\+\(>>\)\+"
155 syn  match         icinga2Operators "[ \t]\+\(<=\)\+"
156 syn  match         icinga2Operators "[ \t]\+\(>=\)\+"
157 syn  match         icinga2Operators "[ \t]\+\(in\)\+"
158 syn  match         icinga2Operators "[ \t]\+\(!in\)\+"
159 syn  match         icinga2Operators "[ \t]\+\(==\)\+"
160 syn  match         icinga2Operators "[ \t]\+\(!=\)\+"
161 syn  match         icinga2Operators "[ \t]\+\(&\)\+"
162 syn  match         icinga2Operators "[ \t]\+\(\^\)\+"
163 syn  match         icinga2Operators "[ \t]\+\(|\)\+"
164 syn  match         icinga2Operators "[ \t]\+\(&&\)\+"
165 syn  match         icinga2Operators "[ \t]\+\(||\)\+"
166 syn  match         icinga2Operators "[ \t]\+\(=>\)\+"
167 syn  match         icinga2Operators "[ \t]\+\(+=\)\+"
168 syn  match         icinga2Operators "[ \t]\+\(-=\)\+"
169 syn  match         icinga2Operators "[ \t]\+\(*=\)\+"
170 syn  match         icinga2Operators "[ \t]\+\(/=\)\+"
171
172 " global constats
173 syn keyword     icinga2Gconst           PrefixDir SysconfDir ZonesDir LocalStateDir RunDir PkgDataDir StatePath ObjectsPath
174 syn keyword     icinga2Gconst           PidPath NodeName ApplicationType EnableNotifications EnableEventHandlers EnableFlapping
175 syn keyword     icinga2Gconst           EnableHostChecks EnableServiceChecks EnablePerfdata UseVfork RunAsUser RunAsGroup PluginDir
176 syn     match           icinga2Gconst           "\(Vars[ \t]\+\)"
177
178 " values type
179 syn keyword             valueBoolean            contained       true false
180 syn keyword             valueNull                       contained       null
181
182
183
184 syn region              nagiosDefBody start='{' end='}'
185         \ contains=icinga2Comment, icinga2LineComment, StringD, Braces, Parens, icinga2ObjDef,
186         \ icinga2ApplyDef, icinga2ObjAttr, icinga2Keyword, icinga2Keyword, icinga2AssignCond,
187         \ icinga2Cond, icinga2Loop, icinga2Operators, icinga2GFunction, icinga2AFunction,
188         \ icinga2MathFunction, icinga2Gconst, icinga2JsonFunction, icinga2StrFunction,
189         \ icinga2ArrFunction, valueBoolean, valueNull
190
191
192 " Highlighting
193 hi link icinga2Comment                          Comment
194 hi link icinga2LineComment                      Comment
195 hi link icinga2CommentTodo                      Todo
196
197 hi link Braces                                          Function
198 hi link Parens                                          Function
199
200 hi link StringS                                         String
201 hi link StringD                                         String
202 hi link angleBrackets                           String
203
204 hi link icinga2ObjDef                           Statement
205 hi link icinga2ApplyDef                         Statement
206 hi link icinga2ObjAttr                          Define
207 hi link icinga2Keyword                          Keyword
208
209 hi link icinga2AssignCond                       Conditional
210
211 hi link icinga2Cond                                     Statement
212 hi link icinga2Loop                                     Statement
213 hi link icinga2Operators                        Operator
214
215 hi link icinga2AFunction                        Function
216 hi link icinga2MathFunction                     Function
217 hi link icinga2GFunction                        Function
218 hi link icinga2JsonFunction                     Function
219 hi link icinga2StrFunction                      Function
220 hi link icinga2ArrFunction                      Function
221
222
223 hi link icinga2Gconst                           Statement
224
225 hi link valueBoolean                            Boolean
226 hi link valueNull                                       Special