Update syntax highlighting (nano/vim) for 2.3 features

fixes #8660
This commit is contained in:
Carlos Cesario 2015-03-12 12:10:15 -03:00 committed by Michael Friedrich
parent 2fc40398c2
commit 76d5b751f4
2 changed files with 198 additions and 43 deletions

View File

@ -4,7 +4,7 @@
syntax "icinga2" "/etc/icinga2/.*\.conf$" "/usr/share/icinga2/include/(plugin|itl|.*\.conf$)" syntax "icinga2" "/etc/icinga2/.*\.conf$" "/usr/share/icinga2/include/(plugin|itl|.*\.conf$)"
## objects types ## 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]+(checkcommand|notificationcommand|eventcommand|notification)"
icolor brightgreen "object[ \t]+(timeperiod|scheduleddowntime|dependency|perfdatawriter)" icolor brightgreen "object[ \t]+(timeperiod|scheduleddowntime|dependency|perfdatawriter)"
icolor brightgreen "object[ \t]+(graphitewriter|idomysqlconnection|idomysqlconnection)" icolor brightgreen "object[ \t]+(graphitewriter|idomysqlconnection|idomysqlconnection)"
@ -13,12 +13,10 @@ icolor brightgreen "object[ \t]+(compatlogger|checkresultreader|checkcomponent
icolor brightgreen "object[ \t]+(filelogger|sysloglogger|icingastatuswriter|apilistener|endpoint|zone)" icolor brightgreen "object[ \t]+(filelogger|sysloglogger|icingastatuswriter|apilistener|endpoint|zone)"
## apply def ## apply def
icolor brightgreen "apply[ \t]+(Service|Dependency|Notification|ScheduledDowntime)" icolor brightgreen "apply[ \t]+(Service|Dependency|Notification|ScheduledDowntime)"
## objects attributes ## objects attributes
icolor red "(^|^\s+)(accept_commands|accept_config|action_url|address|address6|arguments|author|bind_host)" 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+)(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)" icolor red "(^|^\s+)(check_period|child_host_name|child_service_name|cleanup|command|command_endpoint|command_path)"
@ -38,24 +36,97 @@ icolor red "(^|^\s+)(vars\.\w+)"
## keywords ## keywords
icolor red "(^|^\s+)|(icinga2Keyword|template|const|import|include|include_recursive|var|function)\s+"
icolor red "(^|^\s+)|(icinga2Keyword|template|const|import|include|include_recursive)"
## Assign conditions ## Assign conditions
icolor magenta "(assign|ignone)[ \t]+where" icolor magenta "(assign|ignone)[ \t]+where"
## functions ## Global functions
icolor white "(regex|match|len|union|intersection|keys|string|number|bool|random|log|typeof|get_time|exit)"
icolor white "(regex|match|len|union|intersection|string|number|bool|log|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)"
## global constats ## Math functions
icolor yellow "(PrefixDir|SysconfDir|ZonesDir|LocalStateDir|PkgDataDir|RunDir|StatePath|PidPath)" icolor white "(Math.E|Math.LN2|Math.LN10|Math.LOG2E|Math.PI|Math.SQRT1_2|Math.SQRT2)"
icolor yellow "(NodeName|ApplicationType|EnableNotifications|EnableEventHandlers)" icolor white "(Math.abs|Math.acos|Math.asin|Math.atan|Math.atan2|Math.ceil|Math.cos)"
icolor yellow "(EnableFlapping|EnableHostChecks|EnableServiceChecks|EnablePerfdata|UseVfork|RunAsUser|RunAsGroup)" icolor white "(Math.exp|Math.floor|Math.isinf|Math.isnan|Math.log|Math.max|Math.min)"
icolor yellow "(Vars\s+)" 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 ## Boolean
icolor blue "(true|false)" icolor blue "(true|false)"
@ -72,16 +143,15 @@ color brightblue start="/\*" end="\*/"
## Braces and Parens definition ## Braces and Parens definition
# - Braces are used in dictionary definition # - Braces are used in dictionary definition
color brightmagenta "[\[\]]" color magenta "(\(|\))"
color brightmagenta "[()]" color magenta "(\[|\])"
color brightmagenta "[{}]" color magenta "(\{|\})"
## type definitions ## type definitions
# - double quotes " # - double quotes "
# - single quotes ' # - single quotes '
# - brackets <> # - brackets <>
color brightyellow ""(\\.|[^"])*"" color brightyellow "'"
color brightyellow "'(\\.|[^'])*'" color brightyellow """
color brightyellow start="<" end=">" color brightyellow start="<" end=">"

View File

@ -2,7 +2,7 @@
" Filename: icinga2.vim " Filename: icinga2.vim
" Language: Icinga2 object configuration file " Language: Icinga2 object configuration file
" Author: Carlos Cesario <carloscesario@gmail.com> " Author: Carlos Cesario <carloscesario@gmail.com>
" Version: 0.0.1 " Version: 0.0.2
" Based: javascript.vim / nagios.vim " Based: javascript.vim / nagios.vim
" For version 5.x: Clear all syntax items " For version 5.x: Clear all syntax items
@ -26,7 +26,6 @@ syn match icinga2LineComment "\/\/.*" contains=icinga2CommentTodo
syn match icinga2CommentSkip "^[ \t]*\*\($\|[ \t]\+\)" syn match icinga2CommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region icinga2Comment start="/\*" end="\*/" contains=icinga2CommentTodo syn region icinga2Comment start="/\*" end="\*/" contains=icinga2CommentTodo
" type definitions " type definitions
" - double quotes " " - double quotes "
" - single quotes ' " - single quotes '
@ -45,8 +44,7 @@ syn match Parens "[()]"
" objects types " objects types
syn match icinga2ObjDef "object[ \t]\+\(hostgroup\|host\|service\|servicegroup\|user\|usergroup\)"
syn match icinga2ObjDef "object[ \t]\+\(host\|hostgroup\|host\|hostgroup\|service\|servicegroup\|user\|usergroup\)"
syn match icinga2ObjDef "object[ \t]\+\(checkcommand\|notificationcommand\|eventcommand\|notification\)" syn match icinga2ObjDef "object[ \t]\+\(checkcommand\|notificationcommand\|eventcommand\|notification\)"
syn match icinga2Objdef "object[ \t]\+\(timeperiod\|scheduleddowntime\|dependency\|perfdatawriter\)" syn match icinga2Objdef "object[ \t]\+\(timeperiod\|scheduleddowntime\|dependency\|perfdatawriter\)"
syn match icinga2ObjDef "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)" syn match icinga2ObjDef "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)"
@ -56,12 +54,10 @@ syn match icinga2ObjDef "object[ \t]\+\(filelogger\|sysloglogger\|icingastatus
" apply def " apply def
syn match icinga2ApplyDef "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)" syn match icinga2ApplyDef "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)"
" objects attributes " objects attributes
syn keyword icinga2ObjAttr contained accept_commands accept_config action_url address address6 arguments author bind_host 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 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 syn keyword icinga2ObjAttr contained check_period child_host_name child_service_name cleanup command command_endpoint command_path
@ -81,37 +77,116 @@ syn match icinga2ObjAttr contained "\(vars.\w\+\)"
" keywords " keywords
syn keyword icinga2Keyword template const import include include_recursive var function
syn keyword icinga2Keyword template const import include include_recursive
" Assign conditions " Assign conditions
syn match icinga2AssingCond contained "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)"
syn match icinga2ACond contained "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)"
" functions " 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
syn keyword icinga2Function contained regex match len union intersection string number bool log 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 " global constats
syn keyword icinga2Gconst PrefixDir SysconfDir ZonesDir LocalStateDir PkgDataDir RunDir StatePath PidPath syn keyword icinga2Gconst PrefixDir SysconfDir ZonesDir LocalStateDir RunDir PkgDataDir StatePath ObjectsPath
syn keyword icinga2Gconst NodeName ApplicationType EnableNotifications EnableEventHandlers syn keyword icinga2Gconst PidPath NodeName ApplicationType EnableNotifications EnableEventHandlers EnableFlapping
syn keyword icinga2Gconst EnableFlapping EnableHostChecks EnableServiceChecks EnablePerfdata RunAsUser RunAsGroup UseVfork syn keyword icinga2Gconst EnableHostChecks EnableServiceChecks EnablePerfdata UseVfork RunAsUser RunAsGroup PluginDir
syn match icinga2Gconst "\(Vars[ \t]\+\)" syn match icinga2Gconst "\(Vars[ \t]\+\)"
" values type " values type
syn keyword valueBoolean contained true false syn keyword valueBoolean contained true false
syn keyword valueNull contained null syn keyword valueNull contained null
syn region nagiosDefBody start='{' end='}' syn region nagiosDefBody start='{' end='}'
\ contains=icinga2Comment,icinga2LineComment,StringD,Braces,Parens,icinga2ObjDef, \ contains=icinga2Comment, icinga2LineComment, StringD, Braces, Parens, icinga2ObjDef,
\ icinga2ApplyDef,icinga2ObjAttr,icinga2Keyword,icinga2Keyword,icinga2ACond, \ icinga2ApplyDef, icinga2ObjAttr, icinga2Keyword, icinga2Keyword, icinga2AssignCond,
\ icinga2Function,icinga2Gconst,valueBoolean,valueNull \ icinga2Cond, icinga2Loop, icinga2Operators, icinga2GFunction, icinga2AFunction,
\ icinga2MathFunction, icinga2Gconst, icinga2JsonFunction, icinga2StrFunction,
\ icinga2ArrFunction, valueBoolean, valueNull
" Highlighting " Highlighting
@ -131,11 +206,21 @@ hi link icinga2ApplyDef Statement
hi link icinga2ObjAttr Define hi link icinga2ObjAttr Define
hi link icinga2Keyword Keyword hi link icinga2Keyword Keyword
hi link icinga2ACond Conditional hi link icinga2AssignCond Conditional
hi link icinga2Function Function hi link icinga2Cond Statement
hi link icinga2Loop Statement
hi link icinga2Operators Operator
hi link icinga2Gconst Constant 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 icinga2Gconst Statement
hi link valueBoolean Boolean hi link valueBoolean Boolean
hi link valueNull Special hi link valueNull Special