Add icinga2 vim syntax file and installation documentation.

Fixes #3199

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>
This commit is contained in:
Carlos Cesario 2014-05-31 18:38:45 -03:00 committed by Michael Friedrich
parent 25e4e81e50
commit 1b45b814eb
7 changed files with 169 additions and 1 deletions

View File

@ -1,6 +1,7 @@
debian/tmp/etc/icinga2 debian/tmp/etc/icinga2
debian/tmp/etc/logrotate.d debian/tmp/etc/logrotate.d
debian/config/apt.conf etc/icinga2/conf.d/hosts/localhost debian/config/apt.conf etc/icinga2/conf.d/hosts/localhost
tools/syntax/* usr/share/icinga2-common/syntax
usr/bin/icinga2-build* usr/bin/icinga2-build*
usr/bin/icinga2-sign-key usr/bin/icinga2-sign-key
usr/sbin/icinga2-*-feature usr/sbin/icinga2-*-feature

View File

@ -823,6 +823,21 @@ touch with their developers.
If you're looking for puppet manifests, chef cookbooks, ansible recipes, etc - we're happy If you're looking for puppet manifests, chef cookbooks, ansible recipes, etc - we're happy
to integrate them upstream, so please get in touch at [https://support.icinga.org](https://support.icinga.org). to integrate them upstream, so please get in touch at [https://support.icinga.org](https://support.icinga.org).
## <a id="configuration-syntax-highlighting"></a> Configuration Syntax Highlighting
Icinga 2 ships configuration examples for syntax highlighting using the `vim` editor.
The RHEL, SUSE and Debian package `icinga2-common` install these files into
`/usr/share/*/icinga2-common/syntax`. Sources provide these files in `tools/syntax`.
Create a new local vim configuration storage, if not already existing.
Edit `vim/ftdetect/icinga2.vim` if your paths to the Icinga 2 configuration
differ.
$ PREFIX=~/.vim
$ mkdir -p $PREFIX/{syntax,ftdetect}
$ cp vim/syntax/icinga2.vim $PREFIX/syntax/
$ cp vim/ftdetect/icinga2.vim $PREFIX/ftdetect/
## <a id="running-icinga2"></a> Running Icinga 2 ## <a id="running-icinga2"></a> Running Icinga 2

View File

@ -438,7 +438,7 @@ exit 0
%files common %files common
%defattr(-,root,root,-) %defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog tools/syntax
%attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name} %attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name} %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata

1
tools/syntax/README Normal file
View File

@ -0,0 +1 @@
Contains various syntax highlighting scripts for vim, etc.

10
tools/syntax/vim/README Normal file
View File

@ -0,0 +1,10 @@
Icinga 2 Configuration Vim Syntax Highlighting
==============================================
$ PREFIX=~/.vim
$ mkdir -p $PREFIX/{syntax,ftdetect}
$ cp syntax/icinga2.vim $PREFIX/syntax/
$ cp ftdetect/icinga2.vim $PREFIX/ftdetect/
Modify 'ftdetect/icinga2.vim' if your configuration isn't located in
'/etc/icinga2'.

View File

@ -0,0 +1,2 @@
" Modify
au BufNewFile,BufRead /*etc/icinga2/*.conf,/*usr/share/icinga2/include/{itl,plugins,*.conf} set filetype=icinga2

View File

@ -0,0 +1,139 @@
" Vim syntax file
" Filename: icinga2.vim
" Language: Icinga2 object configuration file
" Author: Carlos Cesario <carloscesario@gmail.com>
" Version: 0.0.1
" Based: javascript.vim / nagios.vim
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'icinga2'
endif
" case off
syntax case ignore
" comments
syn keyword icinga2CommentTodo TODO FIXME XXX TBD contained
syn match icinga2LineComment "\/\/.*" contains=icinga2CommentTodo
syn match icinga2CommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region icinga2Comment start="/\*" end="\*/" contains=icinga2CommentTodo
" type definitions
" - double quotes "
" - single quotes '
" - brackets <>
syn region StringD start=+"+ end=+"\|$+
syn region StringS start=+'+ end=+'\|$+
syn match angleBrackets '\<.*\>'
" Braces and Parens definition
" Braces are used in dictionary definition
syn match Braces "[{}\[\]]"
syn match Parens "[()]"
" objects types
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]\+\(timeperiod\|scheduleddowntime\|dependency\|perfdatawriter\)"
syn match icinga2ObjDef "object[ \t]\+\(graphitewriter\|idomysqlconnection\|idomysqlconnection\)"
syn match icinga2ObjDef "object[ \t]\+\(livestatuslistener\|statusdatawriter\|externalcommandlistener\)"
syn match icinga2ObjDef "object[ \t]\+\(compatlogger\|checkresultreader\|checkcomponent\|notificationcomponent\)"
syn match icinga2ObjDef "object[ \t]\+\(filelogger\|sysloglogger\|icingastatuswriter\|apilistener\|endpoint\|zone\)"
" apply def
syn match icinga2ApplyDef "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)"
" objects attributes
syn keyword icinga2ObjAttr contained 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_path
syn keyword icinga2ObjAttr contained comment compat_log_path crl_path database disable_checks disable_notifications
syn keyword icinga2ObjAttr contained display_name duration email enable_active_checks enable_event_handler
syn keyword icinga2ObjAttr contained enable_flap_detection enable_notifications enable_passive_checks enable_perfdata
syn keyword icinga2ObjAttr contained endpoints env event_command fixed flapping_threshold groups host
syn keyword icinga2ObjAttr contained host_format_template host_name host_perfdata_path host_temp_path icon_image
syn keyword icinga2ObjAttr contained icon_image_alt instance_description instance_name interval key_path log_dir
syn keyword icinga2ObjAttr contained log_duration max_check_attempts methods name notes notes_url objects_path
syn keyword icinga2ObjAttr contained pager parent parent_host_name parent_service_name password path period
syn keyword icinga2ObjAttr contained port ranges retry_interval rotation_interval rotation_method
syn keyword icinga2ObjAttr contained service_format_template service_name service_perfdata_path service_temp_path
syn keyword icinga2ObjAttr contained severity socket_path socket_type spool_dir states status_path table_prefix
syn keyword icinga2ObjAttr contained timeout times types update_interval user user_groups users vars volatile
" keywords
syn keyword icinga2Keyword template const import include include_recursive
" 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
" global constats
syn keyword icinga2Gconst contained PrefixDir SysconfDir ZonesDir LocalStateDir PkgDataDir StatePath PidPath
syn keyword icinga2Gconst contained Vars NodeName ApplicationType EnableNotifications EnableEventHandlers
syn keyword icinga2Gconst contained EnableFlapping EnableHostChecks EnableServiceChecks EnablePerfdata UseVfork
" values type
syn keyword valueBoolean contained true false
syn keyword valueNull contained null
syn region icinga2DefBody start='{' end='}'
\ contains=icinga2Comment,icinga2LineComment,StringD,Braces,Parens,icinga2ObjDef,
\ icinga2ApplyDef,icinga2ObjAttr,icinga2Keyword,icinga2Keyword,icinga2ACond,
\ icinga2Function,icinga2Gconst,valueBoolean,valueNull
" Highlighting
hi link icinga2Comment Comment
hi link icinga2LineComment Comment
hi link icinga2CommentTodo Todo
hi link Braces Function
hi link Parens Function
hi link StringS String
hi link StringD String
hi link angleBrackets String
hi link icinga2ObjDef Statement
hi link icinga2ApplyDef Statement
hi link icinga2ObjAttr Define
hi link icinga2Keyword Keyword
hi link icinga2ACond Conditional
hi link icinga2Function Function
hi link icinga2Gconst Constant
hi link valueBoolean Boolean
hi link valueNull Special