From fa515bd5af40ef3738ae3d4b27940f1ac598de30 Mon Sep 17 00:00:00 2001 From: Carlos Cesario Date: Tue, 3 Jun 2014 17:45:24 -0300 Subject: [PATCH] Syntax Highlighting: Add nano syntax file. Fixes #6385 Signed-off-by: Michael Friedrich --- doc/2-getting-started.md | 29 ++++++++++- tools/syntax/README | 2 +- tools/syntax/nano/README | 18 +++++++ tools/syntax/nano/icinga2.nanorc | 87 ++++++++++++++++++++++++++++++++ tools/syntax/vim/README | 5 ++ 5 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 tools/syntax/nano/README create mode 100644 tools/syntax/nano/icinga2.nanorc diff --git a/doc/2-getting-started.md b/doc/2-getting-started.md index 9a3e844a2..a39e993d3 100644 --- a/doc/2-getting-started.md +++ b/doc/2-getting-started.md @@ -825,10 +825,12 @@ to integrate them upstream, so please get in touch at [https://support.icinga.or ## Configuration Syntax Highlighting -Icinga 2 ships configuration examples for syntax highlighting using the `vim` editor. +Icinga 2 ships configuration examples for syntax highlighting using the `vim` and `nano`editors. The RHEL, SUSE and Debian package `icinga2-common` install these files into `/usr/share/*/icinga2-common/syntax`. Sources provide these files in `tools/syntax`. +### Configuration Syntax Highlighting using Vim + 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. @@ -838,6 +840,31 @@ differ. $ cp vim/syntax/icinga2.vim $PREFIX/syntax/ $ cp vim/ftdetect/icinga2.vim $PREFIX/ftdetect/ +Test it: + + $ vim /etc/icinga2/conf.d/templates.conf + +### Configuration Syntax Highlighting using Nano + +Copy the `/etc/nanorc` sample file to your home directory. Create the `/etc/nano` directory +and copy the provided `icinga2.nanorc` into it. + + $ cp /etc/nanorc ~/.nanorc + + # mkdir -p /etc/nano + # cp icinga2.nanorc /etc/nano/ + +Then include the icinga2.nanorc file in your ~/.nanorc by adding the following line: + + $ vim ~/.nanorc + + ## Icinga 2 + include "/etc/nano/icinga2.nanorc" + +Test it: + + $ nano /etc/icinga2/conf.d/templates.conf + ## Running Icinga 2 diff --git a/tools/syntax/README b/tools/syntax/README index cc264c221..f4bf97d83 100644 --- a/tools/syntax/README +++ b/tools/syntax/README @@ -1 +1 @@ -Contains various syntax highlighting scripts for vim, etc. +Contains various syntax highlighting scripts for vim, nano, etc. diff --git a/tools/syntax/nano/README b/tools/syntax/nano/README new file mode 100644 index 000000000..72fb020b2 --- /dev/null +++ b/tools/syntax/nano/README @@ -0,0 +1,18 @@ +Icinga 2 Configuration Nano Syntax Highlighting +=============================================== + +$ cp /etc/nanorc ~/.nanorc + +# mkdir -p /etc/nano +# cp icinga2.nanorc /etc/nano/ + +Then include the icinga2.nanorc file in your ~/.nanorc by adding the following line: + +$ vim ~/.nanorc + +## Icinga 2 +include "/etc/nano/icinga2.nanorc" + +Now test it :-) + +$ nano /etc/icinga2/conf.d/templates.conf diff --git a/tools/syntax/nano/icinga2.nanorc b/tools/syntax/nano/icinga2.nanorc new file mode 100644 index 000000000..9c74f4da3 --- /dev/null +++ b/tools/syntax/nano/icinga2.nanorc @@ -0,0 +1,87 @@ +### Nano synteax file +### Icinga2 object configuration file + +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]+(checkcommand|notificationcommand|eventcommand|notification)" +icolor brightgreen "object[ \t]+(timeperiod|scheduleddowntime|dependency|perfdatawriter)" +icolor brightgreen "object[ \t]+(graphitewriter|idomysqlconnection|idomysqlconnection)" +icolor brightgreen "object[ \t]+(livestatuslistener|statusdatawriter|externalcommandlistener)" +icolor brightgreen "object[ \t]+(compatlogger|checkresultreader|checkcomponent|notificationcomponent)" +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_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_path)" +icolor red "(^|^\s+)(comment|compat_log_path|crl_path|database|disable_checks|disable_notifications)" +icolor red "(^|^\s+)(display_name|duration|email|enable_active_checks|enable_event_handler)" +icolor red "(^|^\s+)(enable_flap_detection|enable_notifications|enable_passive_checks|enable_perfdata)" +icolor red "(^|^\s+)(endpoints|env|event_command|fixed|flapping_threshold|groups|host)" +icolor red "(^|^\s+)(host_format_template|host_name|host_perfdata_path|host_temp_path|icon_image)" +icolor red "(^|^\s+)(icon_image_alt|instance_description|instance_name|interval|key_path|log_dir)" +icolor red "(^|^\s+)(log_duration|max_check_attempts|methods|name|notes|notes_url|objects_path)" +icolor red "(^|^\s+)(pager|parent|parent_host_name|parent_service_name|password|path|period)" +icolor red "(^|^\s+)(port|ranges|retry_interval|rotation_interval|rotation_method)" +icolor red "(^|^\s+)(service_format_template|service_name|service_perfdata_path|service_temp_path)" +icolor red "(^|^\s+)(severity|socket_path|socket_type|spool_dir|states|status_path|table_prefix)" +icolor red "(^|^\s+)(timeout|times|types|update_interval|user|user_groups|users|volatile)" +icolor red "(^|^\s+)(vars\.\w+)" + + +## keywords + +icolor red "(^|^\s+)|(icinga2Keyword|template|const|import|include|include_recursive)" + +## 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|StatePath|PidPath)" +icolor yellow "(NodeName|ApplicationType|EnableNotifications|EnableEventHandlers)" +icolor yellow "(EnableFlapping|EnableHostChecks|EnableServiceChecks|EnablePerfdata|UseVfork)" +icolor yellow "(Vars\s+)" + + +## Boolean +icolor blue "(true|false)" + +# Null +icolor blue "(null)" + + +## comments +color brightblue "\/\/.*" +color brightblue "^[ \t]*\*\($\|[ \t]\+\)" +color brightblue start="/\*" end="\*/" + +## Braces and Parens definition +# - Braces are used in dictionary definition + +color brightmagenta "[\[\]]" +color brightmagenta "[()]" +color brightmagenta "[{}]" + + +## type definitions +# - double quotes " +# - single quotes ' +# - brackets <> + +color brightyellow ""(\\.|[^"])*"" +color brightyellow "'(\\.|[^'])*'" +color brightyellow start="<" end=">" diff --git a/tools/syntax/vim/README b/tools/syntax/vim/README index 11d94699b..b84912f12 100644 --- a/tools/syntax/vim/README +++ b/tools/syntax/vim/README @@ -8,3 +8,8 @@ $ cp ftdetect/icinga2.vim $PREFIX/ftdetect/ Modify 'ftdetect/icinga2.vim' if your configuration isn't located in '/etc/icinga2'. + +Now test it :-) + +$ vim /etc/icinga2/conf.d/templates.conf +