syntax "icinga2" "/etc/icinga2/.*\.conf$" "/usr/share/icinga2/include/(plugin|itl|.*\.conf$)"
## objects types
-icolor brightgreen "object[ \t]+(host|hostgroup|host|hostgroup|service|servicegroup|user|usergroup)"
+icolor brightgreen "object[ \t]+(host|hostgroup|service|servicegroup|user|usergroup)"
icolor brightgreen "object[ \t]+(checkcommand|notificationcommand|eventcommand|notification)"
icolor brightgreen "object[ \t]+(timeperiod|scheduleddowntime|dependency|perfdatawriter)"
icolor brightgreen "object[ \t]+(graphitewriter|idomysqlconnection|idomysqlconnection)"
icolor brightgreen "object[ \t]+(filelogger|sysloglogger|icingastatuswriter|apilistener|endpoint|zone)"
## apply def
-
icolor brightgreen "apply[ \t]+(Service|Dependency|Notification|ScheduledDowntime)"
## objects attributes
-
icolor red "(^|^\s+)(accept_commands|accept_config|action_url|address|address6|arguments|author|bind_host)"
icolor red "(^|^\s+)(bind_port|ca_path|categories|cert_path|check_command|check_interval)"
icolor red "(^|^\s+)(check_period|child_host_name|child_service_name|cleanup|command|command_endpoint|command_path)"
## keywords
-
-icolor red "(^|^\s+)|(icinga2Keyword|template|const|import|include|include_recursive)"
+icolor red "(^|^\s+)|(icinga2Keyword|template|const|import|include|include_recursive|var|function)\s+"
## Assign conditions
-
icolor magenta "(assign|ignone)[ \t]+where"
-## functions
-
-icolor white "(regex|match|len|union|intersection|string|number|bool|log|exit)"
-
-
-## global constats
-icolor yellow "(PrefixDir|SysconfDir|ZonesDir|LocalStateDir|PkgDataDir|RunDir|StatePath|PidPath)"
-icolor yellow "(NodeName|ApplicationType|EnableNotifications|EnableEventHandlers)"
-icolor yellow "(EnableFlapping|EnableHostChecks|EnableServiceChecks|EnablePerfdata|UseVfork|RunAsUser|RunAsGroup)"
-icolor yellow "(Vars\s+)"
-
+## Global functions
+icolor white "(regex|match|len|union|intersection|keys|string|number|bool|random|log|typeof|get_time|exit)"
+
+## Accessor Functions
+icolor white "(get_host|get_service|get_user|get_check_command|get_event_command|get_notification_command)"
+icolor white "(get_host_group|get_service_group|get_user_group|get_time_period)"
+
+
+## Math functions
+icolor white "(Math.E|Math.LN2|Math.LN10|Math.LOG2E|Math.PI|Math.SQRT1_2|Math.SQRT2)"
+icolor white "(Math.abs|Math.acos|Math.asin|Math.atan|Math.atan2|Math.ceil|Math.cos)"
+icolor white "(Math.exp|Math.floor|Math.isinf|Math.isnan|Math.log|Math.max|Math.min)"
+icolor white "(Math.pow|Math.random|Math.round|Math.sign|Math.sin|Math.sqrt|Math.tan)"
+
+## Json functions
+icolor white "(Json.encode|Json.decode)"
+
+## String functions
+icolor white "(\.to_string)"
+icolor white "(\.find)"
+icolor white "(\.contains)"
+icolor white "(\.len)"
+icolor white "(\.lower)"
+icolor white "(\.upper)"
+icolor white "(\.replace)"
+icolor white "(\.split)"
+icolor white "(\.substr)"
+
+## Array and Dict Functions
+icolor white "(\.add)"
+icolor white "(\.clear)"
+icolor white "(\.clone)"
+icolor white "(\.contains)"
+icolor white "(\.len)"
+icolor white "(\.remove)"
+icolor white "(\.set)"
+icolor white "(\.remove)"
+icolor white "(\.sort)"
+icolor white "(\.join)"
+icolor white "(\.clone)"
+icolor white "(\.call)"
+icolor white "(\.callv)"
+
+
+## Conditional statements
+icolor white "(if|else)"
+
+## Loops
+icolor white "(while|for|break|continue)"
+
+## Operators
+icolor green "\s(\.)\s"
+icolor green "\s(!)\s"
+icolor green "\s(\~)\s"
+icolor green "\s(\+)\s"
+icolor green "\s(-)\s"
+icolor green "\s(\*)\s"
+icolor green "\s(/)\s"
+icolor green "\s(%)\s"
+icolor green "\s(=)\s"
+icolor green "\s(<)\s"
+icolor green "\s(>)\s"
+icolor green "\s(<<)\s"
+icolor green "\s(>>)\s"
+icolor green "\s(<=)\s"
+icolor green "\s(>=)\s"
+icolor green "\s(in)\s"
+icolor green "\s(!in)\s"
+icolor green "\s(==)\s"
+icolor green "\s(!=)\s"
+icolor green "\s(&)\s"
+icolor green "\s(\^)\s"
+icolor green "\s(|)\s"
+icolor green "\s(&&)\s"
+icolor green "\s(||)\s"
+icolor green "\s(=>)\s"
+icolor green "\s(\+=)\s"
+icolor green "\s(-=)\s"
+icolor green "\s(\*=)\s"
+icolor green "\s(/=)\s"
+
+## Global constats
+icolor yellow "(PrefixDir|SysconfDir|ZonesDir|LocalStateDir|RunDir|PkgDataDir|StatePath|ObjectsPath)"
+icolor yellow "(PidPath|NodeName|ApplicationType|EnableNotifications|EnableEventHandlers|EnableFlapping)"
+icolor yellow "(EnableHostChecks|EnableServiceChecks|EnablePerfdata|UseVfork|RunAsUser|RunAsGroup|PluginDir)"
+icolor yellow "(Vars\s+)"
## Boolean
icolor blue "(true|false)"
## Braces and Parens definition
# - Braces are used in dictionary definition
-color brightmagenta "[\[\]]"
-color brightmagenta "[()]"
-color brightmagenta "[{}]"
-
+color magenta "(\(|\))"
+color magenta "(\[|\])"
+color magenta "(\{|\})"
## type definitions
# - double quotes "
# - single quotes '
# - brackets <>
-color brightyellow ""(\\.|[^"])*""
-color brightyellow "'(\\.|[^'])*'"
+color brightyellow "'"
+color brightyellow """
color brightyellow start="<" end=">"
" Filename: icinga2.vim
" Language: Icinga2 object configuration file
" Author: Carlos Cesario <carloscesario@gmail.com>
-" Version: 0.0.1
+" Version: 0.0.2
" Based: javascript.vim / nagios.vim
" For version 5.x: Clear all syntax items
syn match icinga2CommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region icinga2Comment start="/\*" end="\*/" contains=icinga2CommentTodo
-
" type definitions
" - double quotes "
" - single quotes '
" objects types
-
-syn match icinga2ObjDef "object[ \t]\+\(host\|hostgroup\|host\|hostgroup\|service\|servicegroup\|user\|usergroup\)"
+syn match icinga2ObjDef "object[ \t]\+\(hostgroup\|host\|service\|servicegroup\|user\|usergroup\)"
syn match icinga2ObjDef "object[ \t]\+\(checkcommand\|notificationcommand\|eventcommand\|notification\)"
syn match icinga2Objdef "object[ \t]\+\(timeperiod\|scheduleddowntime\|dependency\|perfdatawriter\)"
syn match icinga2ObjDef "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)"
" apply def
-
syn match icinga2ApplyDef "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)"
" objects attributes
-
syn keyword icinga2ObjAttr contained accept_commands accept_config action_url address address6 arguments author bind_host
syn keyword icinga2ObjAttr contained bind_port ca_path categories cert_path check_command check_interval
syn keyword icinga2ObjAttr contained check_period child_host_name child_service_name cleanup command command_endpoint command_path
" keywords
-
-syn keyword icinga2Keyword template const import include include_recursive
+syn keyword icinga2Keyword template const import include include_recursive var function
" Assign conditions
-
-syn match icinga2ACond contained "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)"
-
-
-" functions
-
-syn keyword icinga2Function contained regex match len union intersection string number bool log exit
-
+syn match icinga2AssingCond contained "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)"
+
+
+" Global functions
+syn keyword icinga2GFunction contained regex match len union intersection keys string
+syn keyword icinga2GFunction contained number bool random log typeof get_time exit
+
+
+" Accessor Functions
+syn keyword icinga2AFunction contained get_host get_service get_user get_check_command get_event_command get_notification_command
+syn keyword icinga2AFunction contained get_host_group get_service_group get_user_group get_time_period
+
+
+" Math functions
+syn match icinga2MathFunction contained "\(Math.E\|Math.LN2\|Math.LN10\|Math.LOG2E\|Math.PI\|Math.SQRT1_2\|Math.SQRT2\)"
+syn match icinga2MathFunction contained "\(Math.abs\|Math.acos\|Math.asin\|Math.atan\|Math.atan2\|Math.ceil\|Math.cos\)"
+syn match icinga2MathFunction contained "\(Math.exp\|Math.floor\|Math.isinf\|Math.isnan\|Math.log\|Math.max\|Math.min\)"
+syn match icinga2MathFunction contained "\(Math.pow\|Math.random\|Math.round\|Math.sign\|Math.sin\|Math.sqrt\|Math.tan\)"
+
+" Json functions
+syn match icinga2JsonFunction contained "\(Json.encode\|Json.decode\)"
+
+" String functions
+syn match icinga2StrFunction contained "\(\.to_string\)"
+syn match icinga2StrFunction contained "\(\.find\)"
+syn match icinga2StrFunction contained "\(\.contains\)"
+syn match icinga2StrFunction contained "\(\.len\)"
+syn match icinga2StrFunction contained "\(\.lower\)"
+syn match icinga2StrFunction contained "\(\.upper\)"
+syn match icinga2StrFunction contained "\(\.replace\)"
+syn match icinga2StrFunction contained "\(\.split\)"
+syn match icinga2StrFunction contained "\(\.substr\)"
+
+" Array and Dict Functions
+syn match icinga2ArrFunction contained "\(\.add\)"
+syn match icinga2ArrFunction contained "\(\.clear\)"
+syn match icinga2ArrFunction contained "\(\.clone\)"
+syn match icinga2ArrFunction contained "\(\.contains\)"
+syn match icinga2ArrFunction contained "\(\.len\)"
+syn match icinga2ArrFunction contained "\(\.remove\)"
+syn match icinga2ArrFunction contained "\(\.set\)"
+syn match icinga2ArrFunction contained "\(\.remove\)"
+syn match icinga2ArrFunction contained "\(\.sort\)"
+syn match icinga2ArrFunction contained "\(\.join\)"
+syn match icinga2ArrFunction contained "\(\.clone\)"
+syn match icinga2ArrFunction contained "\(\.call\)"
+syn match icinga2ArrFunction contained "\(\.callv\)"
+
+
+" Conditional statements
+syn keyword icinga2Cond if else
+
+" Loops
+syn keyword icinga2Loop while for break continue
+
+" Operators
+syn match icinga2Operators "[ \t]\+\(\.\)\+"
+syn match icinga2Operators "[ \t]\+\(!\)\+"
+syn match icinga2Operators "[ \t]\+\(\~\)\+"
+syn match icinga2Operators "[ \t]\+\(+\)\+"
+syn match icinga2Operators "[ \t]\+\(-\)\+"
+syn match icinga2Operators "[ \t]\+\(*\)\+"
+syn match icinga2Operators "[ \t]\+\(/\)\+"
+syn match icinga2Operators "[ \t]\+\(%\)\+"
+syn match icinga2Operators "[ \t]\+\(+\)\+"
+syn match icinga2Operators "[ \t]\+\(-\)\+"
+syn match icinga2Operators "[ \t]\+\(=\)\+"
+syn match icinga2Operators "[ \t]\+\(<\)[ \t]\+"
+syn match icinga2Operators "[ \t]\+\(>\)[ \t]\+"
+syn match icinga2Operators "[ \t]\+\(<<\)\+"
+syn match icinga2Operators "[ \t]\+\(>>\)\+"
+syn match icinga2Operators "[ \t]\+\(<=\)\+"
+syn match icinga2Operators "[ \t]\+\(>=\)\+"
+syn match icinga2Operators "[ \t]\+\(in\)\+"
+syn match icinga2Operators "[ \t]\+\(!in\)\+"
+syn match icinga2Operators "[ \t]\+\(==\)\+"
+syn match icinga2Operators "[ \t]\+\(!=\)\+"
+syn match icinga2Operators "[ \t]\+\(&\)\+"
+syn match icinga2Operators "[ \t]\+\(\^\)\+"
+syn match icinga2Operators "[ \t]\+\(|\)\+"
+syn match icinga2Operators "[ \t]\+\(&&\)\+"
+syn match icinga2Operators "[ \t]\+\(||\)\+"
+syn match icinga2Operators "[ \t]\+\(=>\)\+"
+syn match icinga2Operators "[ \t]\+\(+=\)\+"
+syn match icinga2Operators "[ \t]\+\(-=\)\+"
+syn match icinga2Operators "[ \t]\+\(*=\)\+"
+syn match icinga2Operators "[ \t]\+\(/=\)\+"
" global constats
-syn keyword icinga2Gconst PrefixDir SysconfDir ZonesDir LocalStateDir PkgDataDir RunDir StatePath PidPath
-syn keyword icinga2Gconst NodeName ApplicationType EnableNotifications EnableEventHandlers
-syn keyword icinga2Gconst EnableFlapping EnableHostChecks EnableServiceChecks EnablePerfdata RunAsUser RunAsGroup UseVfork
+syn keyword icinga2Gconst PrefixDir SysconfDir ZonesDir LocalStateDir RunDir PkgDataDir StatePath ObjectsPath
+syn keyword icinga2Gconst PidPath NodeName ApplicationType EnableNotifications EnableEventHandlers EnableFlapping
+syn keyword icinga2Gconst EnableHostChecks EnableServiceChecks EnablePerfdata UseVfork RunAsUser RunAsGroup PluginDir
syn match icinga2Gconst "\(Vars[ \t]\+\)"
" values type
-
syn keyword valueBoolean contained true false
syn keyword valueNull contained null
-syn region nagiosDefBody start='{' end='}'
- \ contains=icinga2Comment,icinga2LineComment,StringD,Braces,Parens,icinga2ObjDef,
- \ icinga2ApplyDef,icinga2ObjAttr,icinga2Keyword,icinga2Keyword,icinga2ACond,
- \ icinga2Function,icinga2Gconst,valueBoolean,valueNull
+syn region nagiosDefBody start='{' end='}'
+ \ contains=icinga2Comment, icinga2LineComment, StringD, Braces, Parens, icinga2ObjDef,
+ \ icinga2ApplyDef, icinga2ObjAttr, icinga2Keyword, icinga2Keyword, icinga2AssignCond,
+ \ icinga2Cond, icinga2Loop, icinga2Operators, icinga2GFunction, icinga2AFunction,
+ \ icinga2MathFunction, icinga2Gconst, icinga2JsonFunction, icinga2StrFunction,
+ \ icinga2ArrFunction, valueBoolean, valueNull
" Highlighting
hi link icinga2ObjAttr Define
hi link icinga2Keyword Keyword
-hi link icinga2ACond Conditional
+hi link icinga2AssignCond Conditional
+
+hi link icinga2Cond Statement
+hi link icinga2Loop Statement
+hi link icinga2Operators Operator
+
+hi link icinga2AFunction Function
+hi link icinga2MathFunction Function
+hi link icinga2GFunction Function
+hi link icinga2JsonFunction Function
+hi link icinga2StrFunction Function
+hi link icinga2ArrFunction Function
-hi link icinga2Function Function
-hi link icinga2Gconst Constant
+hi link icinga2Gconst Statement
hi link valueBoolean Boolean
-hi link valueNull Special
+hi link valueNull Special