From 9ed3e48495f81742b61c78170e40bbb19bad8290 Mon Sep 17 00:00:00 2001 From: Julian Scharrenbach Date: Fri, 15 Feb 2019 10:46:45 +0100 Subject: [PATCH] =?UTF-8?q?Powershell-VIM=20Ged=C3=B6ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vim/ftdetect/icinga2.vim | 2 + .vim/ftdetect/ps1.vim | 11 + .vim/ftdetect/ps1xml.vim | 8 + .vim/ftdetect/xml.vim | 9 + .vim/ftplugin/ps1.vim | 34 ++++ .vim/ftplugin/ps1xml.vim | 31 +++ .vim/indent/ps1.vim | 20 ++ .vim/registry/vim-icinga2.yaml | 5 + .vim/syntax/icinga2.vim | 360 +++++++++++++++++++++++++++++++++ .vim/syntax/ps1.vim | 185 +++++++++++++++++ .vim/syntax/ps1xml.vim | 56 +++++ 11 files changed, 721 insertions(+) create mode 100644 .vim/ftdetect/icinga2.vim create mode 100644 .vim/ftdetect/ps1.vim create mode 100644 .vim/ftdetect/ps1xml.vim create mode 100644 .vim/ftdetect/xml.vim create mode 100644 .vim/ftplugin/ps1.vim create mode 100644 .vim/ftplugin/ps1xml.vim create mode 100644 .vim/indent/ps1.vim create mode 100644 .vim/registry/vim-icinga2.yaml create mode 100644 .vim/syntax/icinga2.vim create mode 100644 .vim/syntax/ps1.vim create mode 100644 .vim/syntax/ps1xml.vim diff --git a/.vim/ftdetect/icinga2.vim b/.vim/ftdetect/icinga2.vim new file mode 100644 index 0000000..5a78d0a --- /dev/null +++ b/.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/.vim/ftdetect/ps1.vim b/.vim/ftdetect/ps1.vim new file mode 100644 index 0000000..efb7652 --- /dev/null +++ b/.vim/ftdetect/ps1.vim @@ -0,0 +1,11 @@ +" Vim ftdetect plugin file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327 +" +au BufNewFile,BufRead *.ps1 set ft=ps1 +au BufNewFile,BufRead *.psd1 set ft=ps1 +au BufNewFile,BufRead *.psm1 set ft=ps1 +au BufNewFile,BufRead *.pssc set ft=ps1 diff --git a/.vim/ftdetect/ps1xml.vim b/.vim/ftdetect/ps1xml.vim new file mode 100644 index 0000000..4f4bfe9 --- /dev/null +++ b/.vim/ftdetect/ps1xml.vim @@ -0,0 +1,8 @@ +" Vim ftdetect plugin file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327 + +au BufNewFile,BufRead *.ps1xml set ft=ps1xml diff --git a/.vim/ftdetect/xml.vim b/.vim/ftdetect/xml.vim new file mode 100644 index 0000000..2257d48 --- /dev/null +++ b/.vim/ftdetect/xml.vim @@ -0,0 +1,9 @@ +" Vim ftdetect plugin file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327 + +au BufNewFile,BufRead *.cdxml set ft=xml +au BufNewFile,BufRead *.psc1 set ft=xml diff --git a/.vim/ftplugin/ps1.vim b/.vim/ftplugin/ps1.vim new file mode 100644 index 0000000..ae81ccb --- /dev/null +++ b/.vim/ftplugin/ps1.vim @@ -0,0 +1,34 @@ +" Vim filetype plugin file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") | finish | endif + +" Don't load another plug-in for this buffer +let b:did_ftplugin = 1 + +setlocal tw=0 +setlocal commentstring=#%s +setlocal formatoptions=tcqro +" Enable autocompletion of hyphenated PowerShell commands, +" e.g. Get-Content or Get-ADUser +setlocal iskeyword+=- + +" Change the browse dialog on Win32 to show mainly PowerShell-related files +if has("gui_win32") + let b:browsefilter = + \ "All PowerShell Files (*.ps1, *.psd1, *.psm1, *.ps1xml)\t*.ps1;*.psd1;*.psm1;*.ps1xml\n" . + \ "PowerShell Script Files (*.ps1)\t*.ps1\n" . + \ "PowerShell Module Files (*.psd1, *.psm1)\t*.psd1;*.psm1\n" . + \ "PowerShell XML Files (*.ps1xml)\t*.ps1xml\n" . + \ "All Files (*.*)\t*.*\n" +endif + +" Undo the stuff we changed +let b:undo_ftplugin = "setlocal tw< cms< fo<" . + \ " | unlet! b:browsefilter" + diff --git a/.vim/ftplugin/ps1xml.vim b/.vim/ftplugin/ps1xml.vim new file mode 100644 index 0000000..5f615c5 --- /dev/null +++ b/.vim/ftplugin/ps1xml.vim @@ -0,0 +1,31 @@ +" Vim filetype plugin file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") | finish | endif + +" Don't load another plug-in for this buffer +let b:did_ftplugin = 1 + +setlocal tw=0 +setlocal commentstring=#%s +setlocal formatoptions=tcqro + +" Change the browse dialog on Win32 to show mainly PowerShell-related files +if has("gui_win32") + let b:browsefilter = + \ "All PowerShell Files (*.ps1, *.psd1, *.psm1, *.ps1xml)\t*.ps1;*.psd1;*.psm1;*.ps1xml\n" . + \ "PowerShell Script Files (*.ps1)\t*.ps1\n" . + \ "PowerShell Module Files (*.psd1, *.psm1)\t*.psd1;*.psm1\n" . + \ "PowerShell XML Files (*.ps1xml)\t*.ps1xml\n" . + \ "All Files (*.*)\t*.*\n" +endif + +" Undo the stuff we changed +let b:undo_ftplugin = "setlocal tw< cms< fo<" . + \ " | unlet! b:browsefilter" + diff --git a/.vim/indent/ps1.vim b/.vim/indent/ps1.vim new file mode 100644 index 0000000..9eac9c9 --- /dev/null +++ b/.vim/indent/ps1.vim @@ -0,0 +1,20 @@ +" Vim indent file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327" + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" smartindent is good enough for powershell +setlocal smartindent +" disable the indent removal for # marks +inoremap # X# + +let b:undo_indent = "setl si<" + diff --git a/.vim/registry/vim-icinga2.yaml b/.vim/registry/vim-icinga2.yaml new file mode 100644 index 0000000..483a067 --- /dev/null +++ b/.vim/registry/vim-icinga2.yaml @@ -0,0 +1,5 @@ +addon: icinga2 +description: "Syntax highlighting for Icinga 2" +files: + - ftdetect/icinga2.vim + - syntax/icinga2.vim diff --git a/.vim/syntax/icinga2.vim b/.vim/syntax/icinga2.vim new file mode 100644 index 0000000..0374c7b --- /dev/null +++ b/.vim/syntax/icinga2.vim @@ -0,0 +1,360 @@ +" Vim syntax file +" Filename: icinga2.vim +" Language: Icinga2 object configuration file +" Author: Carlos Cesario , Michael Friedrich +" Version: 1.0.0 +" 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 + +" ######################################## +" ### General settings + +" comments +syn keyword icinga2CommentTodo TODO FIXME XXX TBD contained +syn match icinga2LineComment "\/\/.*" contains=icinga2CommentTodo +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 match angleBrackets "<.*>" +syn region macro start=+\$+ end=+\$+ oneline +syn region StringD start=+"+ end=+"\|$+ contains=macro +syn region StringS start=+'+ end=+'\|$+ contains=macro + + +" Braces and Parens definition +" Braces are used in dictionary definition + +syn match Braces "[{}\[\]]" +syn match Parens "[()]" +syn match Lambda "{{}}" + + +" ######################################## +" ### Match objects, attributes and keywords + +" Object types +syn keyword icinga2ObjType ApiListener ApiUser CheckCommand CheckerComponent +syn keyword icinga2ObjType Comment Dependency Downtime ElasticsearchWriter +syn keyword icinga2ObjType Endpoint EventCommand ExternalCommandListener +syn keyword icinga2ObjType FileLogger GelfWriter GraphiteWriter Host HostGroup +syn keyword icinga2ObjType IcingaApplication IdoMysqlConnection IdoPgsqlConnection +syn keyword icinga2ObjType InfluxdbWriter LivestatusListener Notification NotificationCommand +syn keyword icinga2ObjType NotificationComponent OpenTsdbWriter PerfdataWriter +syn keyword icinga2ObjType ScheduledDowntime Service ServiceGroup SyslogLogger +syn keyword icinga2ObjType TimePeriod User UserGroup Zone + +" Object/Template marker (simplified) +syn match icinga2ObjDef "\(object\|template\)[ \t]\+.*" + +" Apply rules +syn match icinga2ApplyDef "apply[ \t]\+\(Service\|Dependency\|Notification\|ScheduledDowntime\)" + + +" Objects attributes +" +" find . -type f -name '*.ti' -exec sh -c 'grep config {}' \; +" Don't add 'host', etc. from apply rules here, they should match icinga2ObjType instead. +syn keyword icinga2ObjAttr contained accept_commands accept_config access_control_allow_origin 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 check_timeout child_host_name child_options child_service_name cipher_list +syn keyword icinga2ObjAttr contained cleanup client_cn command command_endpoint command_path +syn keyword icinga2ObjAttr contained comment compat_log_path concurrent_checks crl_path database disable_checks disable_notifications +syn keyword icinga2ObjAttr contained display_name duration email enable_active_checks enable_event_handlers enable_event_handler +syn keyword icinga2ObjAttr contained enable_flapping enable_ha enable_host_checks enable_notifications enable_passive_checks enable_perfdata +syn keyword icinga2ObjAttr contained enable_send_metadata enable_send_perfdata enable_send_thresholds enable_tls enable_service_checks +syn keyword icinga2ObjAttr contained endpoints env event_command excludes failover_timeout fixed flapping_threshold_low flapping_threshold_high +syn keyword icinga2ObjAttr contained flush_interval flush_threshold global groups +syn keyword icinga2ObjAttr contained host_format_template host_name host_name_template host_perfdata_path host_temp_path host_template icon_image +syn keyword icinga2ObjAttr contained icon_image_alt ignore_soft_states includes index instance_description instance_name interval key_path log_dir +syn keyword icinga2ObjAttr contained log_duration max_anonymous_clients 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 permissions +syn keyword icinga2ObjAttr contained port prefer_includes ranges retry_interval rotation_interval rotation_method +syn keyword icinga2ObjAttr contained service_format_template service_name service_name_template service_perfdata_path service_temp_path service_template +syn keyword icinga2ObjAttr contained severity socket_path socket_type source spool_dir +syn keyword icinga2ObjAttr contained ssl_ca ssl_capath ssl_ca_cert ssl_cert ssl_cipher ssl_enable ssl_mode ssl_key +syn keyword icinga2ObjAttr contained states status_path table_prefix ticket_salt +syn keyword icinga2ObjAttr contained timeout times tls_handshake_timeout tls_protocolmin +syn keyword icinga2ObjAttr contained types update_interval user user_groups username users volatile zone +syn match icinga2ObjAttr contained "\(vars.\w\+\)" + +" keywords: https://icinga.com/docs/icinga2/latest/doc/17-language-reference/#reserved-keywords +syn keyword icinga2Keyword object template include include_recursive include_zones library +syn keyword icinga2Keyword const var this globals locals use default ignore_on_error +syn keyword icinga2Keyword current_filename current_line apply to where import assign +syn keyword icinga2Keyword ignore function return in + + +" Assign conditions +syn match icinga2AssignCond contained "\(assign[ \t]\+\where\|ignore[ \t]\+\where\)" + + +" Documentation reference: https://icinga.com/docs/icinga2/latest/doc/18-library-reference/ + +" Global functions +syn keyword icinga2GFunction contained regex match cidr_match range len union intersection keys string +syn keyword icinga2GFunction contained number bool random log typeof get_time parse_performance_data dirname +syn keyword icinga2GFunction contained basename path_exists glob glob_recursive +syn keyword icinga2GFunction contained escape_shell_arg escape_shell_cmd escape_create_process_arg sleep exit +syn keyword icinga2GFunction contained macro + + +" Accessor Functions +syn keyword icinga2AFunction contained get_check_command get_event_command get_notification_command +syn keyword icinga2AFunction contained get_host get_service get_services get_user +syn keyword icinga2AFunction contained get_host_group get_service_group get_user_group +syn keyword icinga2AFunction contained get_timeperiod +syn keyword icinga2AFunction contained get_object get_objects + +" 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\)" + +" Number functions +syn match icinga2NumberFunction contained "\(\.to_string\)" + +" Boolean functions +syn match icinga2BoolFunction contained "\(\.to_string\)" + +" String functions +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\)" +syn match icinga2StrFunction contained "\(\.to_string\)" +syn match icinga2StrFunction contained "\(\.reverse\)" +syn match icinga2StrFunction contained "\(\.trim\)" + +" Object functions +syn match icinga2ObjectFunction contained "\(\.clone\)" +syn match icinga2ObjectFunction contained "\(\.to_string\)" +syn match icinga2ObjectFunction contained "\(\.type\)" + +" Type functions +syn match icinga2TypeFunction contained "\(\.base\)" +" needs an exception for 'vars' +syn match icinga2TypeFunction contained "\(^[vars]\.name\)" +syn match icinga2TypeFunction contained "\(\.prototype\)" + +" Array functions +syn match icinga2ArrFunction contained "\(\.add(\)" +syn match icinga2ArrFunction contained "\(\.clear\)" +syn match icinga2ArrFunction contained "\(\.shallow_clone\)" +syn match icinga2ArrFunction contained "\(\.contains\)" +syn match icinga2ArrFunction contained "\(\.freeze\)" +syn match icinga2ArrFunction contained "\(\.len\)" +syn match icinga2ArrFunction contained "\(\.remove\)" +syn match icinga2ArrFunction contained "\(\.set\)" +syn match icinga2ArrFunction contained "\(\.get\)" +syn match icinga2ArrFunction contained "\(\.sort\)" +syn match icinga2ArrFunction contained "\(\.join\)" +syn match icinga2ArrFunction contained "\(\.reverse\)" +syn match icinga2ArrFunction contained "\(\.map\)" +syn match icinga2ArrFunction contained "\(\.reduce\)" +syn match icinga2ArrFunction contained "\(\.filter\)" +syn match icinga2ArrFunction contained "\(\.any\)" +syn match icinga2ArrFunction contained "\(\.all\)" + +" Dictionary functions +syn match icinga2DictFunction contained "\(\.shallow_clone\)" +syn match icinga2DictFunction contained "\(\.contains\)" +syn match icinga2DictFunction contained "\(\.freeze\)" +syn match icinga2DictFunction contained "\(\.len\)" +syn match icinga2DictFunction contained "\(\.remove\)" +syn match icinga2DictFunction contained "\(\.set\)" +syn match icinga2DictFunction contained "\(\.get\)" +syn match icinga2DictFunction contained "\(\.keys\)" +syn match icinga2DictFunction contained "\(\.values\)" + +" Function functions +syn match icinga2FuncFunction contained "\(\.call\)" +syn match icinga2FuncFunction contained "\(\.callv\)" + +" DateTime functions +syn match icinga2DTFunction contained "\(DateTime\)" +syn match icinga2DTFunction contained "\(\.format\)" +syn match icinga2DTFunction contained "\(\.to_string\)" + +" Conditional statements +syn keyword icinga2Cond if else + +" Loops +syn keyword icinga2Loop while for break continue + +" Exceptions +syn keyword icinga2Exception throw try except + +" Debugger +syn keyword icinga2Debugger debugger + +" References +syn keyword icinga2Reference & * +" Namespace +syn keyword icinga2Namespace namespace using + +" 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 settings + +" Global constants +" https://icinga.com/docs/icinga2/snapshot/doc/17-language-reference/#icinga-2-specific-constants + +" Path specific constants +syn keyword icinga2PathConstant CacheDir ConfigDir DataDir IncludeConfDir InitRunDir LocalStateDir LogDir ModAttrPath +syn keyword icinga2PathConstant ObjectsPath PidPath PkgDataDir PrefixDir ProgramData RunDir SpoolDir StatePath SysconfDir +syn keyword icinga2PathConstant VarsPath ZonesDir + +" Global constants +syn keyword icinga2GlobalConstant Vars NodeName Environment RunAsUser RunAsGroup MaxConcurrentChecks ApiBindHost ApiBindPort EventEngine AttachDebugger + +" Application runtime constants +syn keyword icinga2GlobalConstant PlatformName PlatformVersion PlatformKernel PlatformKernelVersion BuildCompilerName BuildCompilerVersion BuildHostName +syn keyword icinga2GlobalConstant ApplicationVersion + +" User proposed constants +syn keyword icinga2UserConstant PluginDir ContribPluginContribDir ManubulonPluginDir TicketSalt NodeName ZoneName + +" Global types +syn keyword icinga2GlobalType Number String Boolean Array Dictionary Value Object ConfigObject Command CheckResult +syn keyword icinga2GlobalType Checkable CustomVarObject DbConnection Type PerfdataValue Comment Downtime Logger Application + +" Built-in Namespaces +syn match icinga2Namespace contained "\(Icinga\.\|Internal\.\|System\.Configuration\.\|System\.\)" + +" Additional constants from Namespaces +syn keyword icinga2GlobalConstant LogCritical LogDebug LogInformation LogNotice LogWarning MatchAll MatchAny +" icinga2 console; keys(Icinga).join(" ") +syn keyword icinga2GlobalConstant Acknowledgement Critical Custom DbCatAcknowledgement DbCatCheck DbCatComment DbCatConfig DbCatDowntime DbCatEventHandler DbCatEverything DbCatExternalCommand DbCatFlapping DbCatLog DbCatNotification DbCatProgramStatus DbCatRetention DbCatState DbCatStateHistory Down DowntimeEnd DowntimeNoChildren DowntimeNonTriggeredChildren DowntimeRemoved DowntimeStart DowntimeTriggeredChildren FlappingEnd FlappingStart HostDown HostUp OK Problem Recovery ServiceCritical ServiceOK ServiceUnknown ServiceWarning Unknown Up Warning + +" Value types +"syn match valueNumber "[0-9]*" +syn keyword valueBoolean contained true false +syn keyword valueNull contained null + + +" ######################################## +" ### Where to apply + +syn region icingaDefBody start='{' end='}' + \ contains=icinga2Comment, icinga2LineComment, StringS, StringD, macro, Braces, Parens, Lambda, icinga2ObjType, icinga2ObjDef, + \ icinga2ApplyDef, icinga2ObjAttr, icinga2Keyword, icinga2AssignCond, + \ icinga2Cond, icinga2Loop, icinga2Exception, icinga2Debugger, icinga2Operators, icinga2GFunction, icinga2AFunction, + \ icinga2MathFunction, icinga2GlobalConstant, icinga2PathConstant, icinga2UserConstant, icinga2Gconst, icinga2Namespace, + \ icinga2JsonFunction, icinga2NumberFunction, icinga2BoolFunction, + \ icinga2StrFunction, icinga2ObjectFunction, icinga2TypeFunction, icinga2ArrFunction, icinga2DictFunction, + \ icinga2DTFunction, valueNumber, 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 Lambda Function + +hi link macro Underlined +hi link StringS String +hi link StringD String +hi link angleBrackets String + +hi link icinga2ObjType Type +hi link icinga2ObjDef Statement + +hi link icinga2ApplyDef Statement +hi link icinga2ObjAttr Define +hi link icinga2Keyword Keyword + +hi link icinga2AssignCond Conditional + +hi link icinga2Cond Conditional +hi link icinga2Loop Repeat +hi link icinga2Exception Conditional +hi link icinga2Debugger Debug + +hi link icinga2Operators Operator + +hi link icinga2AFunction Function +hi link icinga2MathFunction Function +hi link icinga2GFunction Function +hi link icinga2JsonFunction Function +hi link icinga2NumberFunction Function +hi link icinga2BoolFunction Function +hi link icinga2StrFunction Function +hi link icinga2ObjectFunction Function +hi link icinga2TypeFunction Function +hi link icinga2ArrFunction Function +hi link icinga2DictFunction Function +hi link icinga2DTFunction Function + +hi link icinga2GlobalConstant Statement +hi link icinga2PathConstant Statement +hi link icinga2UserConstant Statement +hi link icinga2Gconst Statement +hi link icinga2Namespace Statement + +hi link valueNumber Number +hi link valueBoolean Boolean +hi link valueNull Special diff --git a/.vim/syntax/ps1.vim b/.vim/syntax/ps1.vim new file mode 100644 index 0000000..d034280 --- /dev/null +++ b/.vim/syntax/ps1.vim @@ -0,0 +1,185 @@ +" Vim syntax file +" Language: Windows PowerShell +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327" +" +" The following settings are available for tuning syntax highlighting: +" let ps1_nofold_blocks = 1 +" let ps1_nofold_sig = 1 +" let ps1_nofold_region = 1 + +" Compatible VIM syntax file start +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Operators contain dashes +setlocal iskeyword+=- + +" PowerShell doesn't care about case +syn case ignore + +" Sync-ing method +syn sync minlines=100 + +" Certain tokens can't appear at the top level of the document +syn cluster ps1NotTop contains=@ps1Comment,ps1CDocParam,ps1FunctionDeclaration + +" Comments and special comment words +syn keyword ps1CommentTodo TODO FIXME XXX TBD HACK NOTE contained +syn match ps1CDocParam /.*/ contained +syn match ps1CommentDoc /^\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained +syn match ps1CommentDoc /#\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained +syn match ps1Comment /#.*/ contains=ps1CommentTodo,ps1CommentDoc,@Spell +syn region ps1Comment start="<#" end="#>" contains=ps1CommentTodo,ps1CommentDoc,@Spell + +" Language keywords and elements +syn keyword ps1Conditional if else elseif switch default +syn keyword ps1Repeat while for do until break continue foreach in +syn match ps1Repeat /\/ nextgroup=ps1Block skipwhite +syn match ps1Keyword /\/ nextgroup=ps1Block skipwhite +syn match ps1Keyword /\/ nextgroup=ps1Block skipwhite + +syn keyword ps1Exception begin process end exit inlinescript parallel sequence +syn keyword ps1Keyword try catch finally throw +syn keyword ps1Keyword return filter in trap param data dynamicparam +syn keyword ps1Constant $true $false $null +syn match ps1Constant +\$?+ +syn match ps1Constant +\$_+ +syn match ps1Constant +\$\$+ +syn match ps1Constant +\$^+ + +" Keywords reserved for future use +syn keyword ps1Keyword class define from using var + +" Function declarations +syn keyword ps1Keyword function nextgroup=ps1FunctionDeclaration skipwhite +syn keyword ps1Keyword filter nextgroup=ps1FunctionDeclaration skipwhite +syn keyword ps1Keyword workflow nextgroup=ps1FunctionDeclaration skipwhite +syn keyword ps1Keyword configuration nextgroup=ps1FunctionDeclaration skipwhite +syn keyword ps1Keyword class nextgroup=ps1FunctionDeclaration skipwhite +syn keyword ps1Keyword enum nextgroup=ps1FunctionDeclaration skipwhite +syn match ps1FunctionDeclaration /\w\+\(-\w\+\)*/ contained + +" Function invocations +syn match ps1FunctionInvocation /\w\+\(-\w\+\)\+/ + +" Type declarations +syn match ps1Type /\[[a-z_][a-z0-9_.,\[\]]\+\]/ + +" Variable references +syn match ps1ScopeModifier /\(global:\|local:\|private:\|script:\)/ contained +syn match ps1Variable /\$\w\+\(:\w\+\)\?/ contains=ps1ScopeModifier +syn match ps1Variable /\${\w\+\(:\w\+\)\?}/ contains=ps1ScopeModifier + +" Operators +syn keyword ps1Operator -eq -ne -ge -gt -lt -le -like -notlike -match -notmatch -replace -split -contains -notcontains +syn keyword ps1Operator -ieq -ine -ige -igt -ile -ilt -ilike -inotlike -imatch -inotmatch -ireplace -isplit -icontains -inotcontains +syn keyword ps1Operator -ceq -cne -cge -cgt -clt -cle -clike -cnotlike -cmatch -cnotmatch -creplace -csplit -ccontains -cnotcontains +syn keyword ps1Operator -in -notin +syn keyword ps1Operator -is -isnot -as -join +syn keyword ps1Operator -and -or -not -xor -band -bor -bnot -bxor +syn keyword ps1Operator -f +syn match ps1Operator /!/ +syn match ps1Operator /=/ +syn match ps1Operator /+=/ +syn match ps1Operator /-=/ +syn match ps1Operator /\*=/ +syn match ps1Operator /\/=/ +syn match ps1Operator /%=/ +syn match ps1Operator /+/ +syn match ps1Operator /-\(\s\|\d\|\.\|\$\|(\)\@=/ +syn match ps1Operator /\*/ +syn match ps1Operator /\// +syn match ps1Operator /|/ +syn match ps1Operator /%/ +syn match ps1Operator /&/ +syn match ps1Operator /::/ +syn match ps1Operator /,/ +syn match ps1Operator /\(^\|\s\)\@<=\. \@=/ + +" Regular Strings +" These aren't precisely correct and could use some work +syn region ps1String start=/"/ skip=/`"/ end=/"/ contains=@ps1StringSpecial,@Spell +syn region ps1String start=/'/ skip=/''/ end=/'/ + +" Here-Strings +syn region ps1String start=/@"$/ end=/^"@/ contains=@ps1StringSpecial,@Spell +syn region ps1String start=/@'$/ end=/^'@/ + +" Interpolation +syn match ps1Escape /`./ +syn region ps1Interpolation matchgroup=ps1InterpolationDelimiter start="$(" end=")" contained contains=ALLBUT,@ps1NotTop +syn region ps1NestedParentheses start="(" skip="\\\\\|\\)" matchgroup=ps1Interpolation end=")" transparent contained +syn cluster ps1StringSpecial contains=ps1Escape,ps1Interpolation,ps1Variable,ps1Boolean,ps1Constant,ps1BuiltIn,@Spell + +" Numbers +syn match ps1Number "\(\<\|-\)\@<=\(0[xX]\x\+\|\d\+\)\([KMGTP][B]\)\=\(\>\|-\)\@=" +syn match ps1Number "\(\(\<\|-\)\@<=\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[dD]\=" +syn match ps1Number "\<\d\+[eE][-+]\=\d\+[dD]\=\>" +syn match ps1Number "\<\d\+\([eE][-+]\=\d\+\)\=[dD]\>" + +" Constants +syn match ps1Boolean "$\%(true\|false\)\>" +syn match ps1Constant /\$null\>/ +syn match ps1BuiltIn "$^\|$?\|$_\|$\$" +syn match ps1BuiltIn "$\%(args\|error\|foreach\|home\|input\)\>" +syn match ps1BuiltIn "$\%(match\(es\)\?\|myinvocation\|host\|lastexitcode\)\>" +syn match ps1BuiltIn "$\%(ofs\|shellid\|stacktrace\)\>" + +" Folding blocks +if !exists('g:ps1_nofold_blocks') + syn region ps1Block start=/{/ end=/}/ transparent fold +endif + +if !exists('g:ps1_nofold_region') + syn region ps1Region start=/#region/ end=/#endregion/ transparent fold keepend extend +endif + +if !exists('g:ps1_nofold_sig') + syn region ps1Signature start=/# SIG # Begin signature block/ end=/# SIG # End signature block/ transparent fold +endif + +" Setup default color highlighting +if version >= 508 || !exists("did_ps1_syn_inits") + if version < 508 + let did_ps1_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink ps1Number Number + HiLink ps1Block Block + HiLink ps1Region Region + HiLink ps1Exception Exception + HiLink ps1Constant Constant + HiLink ps1String String + HiLink ps1Escape SpecialChar + HiLink ps1InterpolationDelimiter Delimiter + HiLink ps1Conditional Conditional + HiLink ps1FunctionDeclaration Function + HiLink ps1FunctionInvocation Function + HiLink ps1Variable Identifier + HiLink ps1Boolean Boolean + HiLink ps1Constant Constant + HiLink ps1BuiltIn StorageClass + HiLink ps1Type Type + HiLink ps1ScopeModifier StorageClass + HiLink ps1Comment Comment + HiLink ps1CommentTodo Todo + HiLink ps1CommentDoc Tag + HiLink ps1CDocParam Todo + HiLink ps1Operator Operator + HiLink ps1Repeat Repeat + HiLink ps1RepeatAndCmdlet Repeat + HiLink ps1Keyword Keyword + HiLink ps1KeywordAndCmdlet Keyword + delcommand HiLink +endif + +let b:current_syntax = "ps1" diff --git a/.vim/syntax/ps1xml.vim b/.vim/syntax/ps1xml.vim new file mode 100644 index 0000000..02407f5 --- /dev/null +++ b/.vim/syntax/ps1xml.vim @@ -0,0 +1,56 @@ +" Vim syntax file +" Language: Windows PowerShell XML +" Maintainer: Peter Provost +" Version: 2.10 +" Project Repository: https://github.com/PProvost/vim-ps1 +" Vim Script Page: http://www.vim.org/scripts/script.php?script_id=1327" + +" Compatible VIM syntax file start +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +let s:ps1xml_cpo_save = &cpo +set cpo&vim + +doau syntax xml +unlet b:current_syntax + +syn case ignore +syn include @ps1xmlScriptBlock :p:h/ps1.vim +unlet b:current_syntax + +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend + +syn cluster xmlRegionHook add=ps1xmlScriptBlock + +let b:current_syntax = "ps1xml" + +let &cpo = s:ps1xml_cpo_save +unlet s:ps1xml_cpo_save +