[icinga-checkins] icinga.org: icinga2/next: Add icinga2 vim syntax file and installation documentation.

git at icinga.org git at icinga.org
Mon Jun 2 16:30:19 CEST 2014


Module: icinga2
Branch: next
Commit: 1b45b814eb489cd6fe03c4c8c78d4ab9202c4710
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=1b45b814eb489cd6fe03c4c8c78d4ab9202c4710

Author: Carlos Cesario <carloscesario at gmail.com>
Date:   Sat May 31 18:38:45 2014 -0300

Add icinga2 vim syntax file and installation documentation.

Fixes #3199

Signed-off-by: Michael Friedrich <michael.friedrich at netways.de>

---

 debian/icinga2-common.install         |    1 +
 doc/2-getting-started.md              |   15 ++++
 icinga2.spec                          |    2 +-
 tools/syntax/README                   |    1 +
 tools/syntax/vim/README               |   10 +++
 tools/syntax/vim/ftdetect/icinga2.vim |    2 +
 tools/syntax/vim/syntax/icinga2.vim   |  139 +++++++++++++++++++++++++++++++++
 7 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/debian/icinga2-common.install b/debian/icinga2-common.install
index a9f7256..ea173a3 100644
--- a/debian/icinga2-common.install
+++ b/debian/icinga2-common.install
@@ -1,6 +1,7 @@
 debian/tmp/etc/icinga2
 debian/tmp/etc/logrotate.d
 debian/config/apt.conf        etc/icinga2/conf.d/hosts/localhost
+tools/syntax/* 		      usr/share/icinga2-common/syntax
 usr/bin/icinga2-build*
 usr/bin/icinga2-sign-key
 usr/sbin/icinga2-*-feature
diff --git a/doc/2-getting-started.md b/doc/2-getting-started.md
index 6ef2e51..9a3e844 100644
--- a/doc/2-getting-started.md
+++ b/doc/2-getting-started.md
@@ -823,6 +823,21 @@ touch with their developers.
 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).
 
+## <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
 
diff --git a/icinga2.spec b/icinga2.spec
index 5fffec1..c871748 100644
--- a/icinga2.spec
+++ b/icinga2.spec
@@ -438,7 +438,7 @@ exit 0
 
 %files common
 %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(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
diff --git a/tools/syntax/README b/tools/syntax/README
new file mode 100644
index 0000000..cc264c2
--- /dev/null
+++ b/tools/syntax/README
@@ -0,0 +1 @@
+Contains various syntax highlighting scripts for vim, etc.
diff --git a/tools/syntax/vim/README b/tools/syntax/vim/README
new file mode 100644
index 0000000..11d9469
--- /dev/null
+++ b/tools/syntax/vim/README
@@ -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'.
diff --git a/tools/syntax/vim/ftdetect/icinga2.vim b/tools/syntax/vim/ftdetect/icinga2.vim
new file mode 100644
index 0000000..5a78d0a
--- /dev/null
+++ b/tools/syntax/vim/ftdetect/icinga2.vim
@@ -0,0 +1,2 @@
+" Modify
+au BufNewFile,BufRead /*etc/icinga2/*.conf,/*usr/share/icinga2/include/{itl,plugins,*.conf} set filetype=icinga2
diff --git a/tools/syntax/vim/syntax/icinga2.vim b/tools/syntax/vim/syntax/icinga2.vim
new file mode 100644
index 0000000..b4d4fa2
--- /dev/null
+++ b/tools/syntax/vim/syntax/icinga2.vim
@@ -0,0 +1,139 @@
+" Vim syntax file
+" Filename:     icinga2.vim
+" Language:     Icinga2 object configuration file
+" Author:	Carlos Cesario <carloscesario at 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



More information about the icinga-checkins mailing list