├── LICENSE ├── README.md ├── ftdetect └── helm.vim └── syntax └── helm.vim /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Tobias Wolf 2 | All rights reserved. 3 | 4 | Contains syntax portions licensed from: 5 | https://github.com/fatih/vim-go 6 | 7 | Copyright (c) 2015, Fatih Arslan 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | * Neither the name of the copyright holder nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-helm 2 | vim syntax for helm templates (yaml + gotmpl + sprig + custom) 3 | 4 | Install via vundle: 5 | 6 | ```vim 7 | Plugin 'towolf/vim-helm' 8 | ``` 9 | -------------------------------------------------------------------------------- /ftdetect/helm.vim: -------------------------------------------------------------------------------- 1 | function! s:isHelm() 2 | let filepath = expand("%:p") 3 | 4 | " yaml/yml/tpl/txt inside templates dir 5 | if filepath =~ '\v/(templates)/.*\.(ya?ml|tpl|txt)$' | return 1 | endif 6 | 7 | let filename = expand("%:t") 8 | 9 | " helmfile templated values 10 | if filename =~ '\v.*\.gotmpl$' | return 1 | endif 11 | 12 | " helmfile.yaml / helmfile-my.yaml / helmfile_my.yaml etc 13 | if filename =~ '\v(helmfile).*\.ya?ml$' | return 1 | endif 14 | 15 | return 0 16 | endfunction 17 | 18 | autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | endif 19 | 20 | " Use {{/* */}} as comments 21 | autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} 22 | -------------------------------------------------------------------------------- /syntax/helm.vim: -------------------------------------------------------------------------------- 1 | if exists("b:current_syntax") 2 | finish 3 | endif 4 | 5 | if !exists("main_syntax") 6 | let main_syntax = 'yaml' 7 | endif 8 | 9 | let b:current_syntax = '' 10 | unlet b:current_syntax 11 | runtime! syntax/yaml.vim 12 | 13 | let b:current_syntax = '' 14 | unlet b:current_syntax 15 | syntax include @Yaml syntax/yaml.vim 16 | 17 | syn case match 18 | 19 | " Go escapes 20 | syn match goEscapeOctal display contained "\\[0-7]\{3}" 21 | syn match goEscapeC display contained +\\[abfnrtv\\'"]+ 22 | syn match goEscapeX display contained "\\x\x\{2}" 23 | syn match goEscapeU display contained "\\u\x\{4}" 24 | syn match goEscapeBigU display contained "\\U\x\{8}" 25 | syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ 26 | 27 | hi def link goEscapeOctal goSpecialString 28 | hi def link goEscapeC goSpecialString 29 | hi def link goEscapeX goSpecialString 30 | hi def link goEscapeU goSpecialString 31 | hi def link goEscapeBigU goSpecialString 32 | hi def link goSpecialString Special 33 | hi def link goEscapeError Error 34 | 35 | " Strings and their contents 36 | syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError 37 | syn region goString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup 38 | syn region goRawString contained start=+`+ end=+`+ 39 | 40 | hi def link goString String 41 | hi def link goRawString String 42 | 43 | " Characters; their contents 44 | syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU 45 | syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup 46 | 47 | hi def link goCharacter Character 48 | 49 | " Integers 50 | syn match goDecimalInt contained "\<\d\+\([Ee]\d\+\)\?\>" 51 | syn match goHexadecimalInt contained "\<0x\x\+\>" 52 | syn match goOctalInt contained "\<0\o\+\>" 53 | syn match goOctalError contained "\<0\o*[89]\d*\>" 54 | syn cluster goInt contains=goDecimalInt,goHexadecimalInt,goOctalInt 55 | " Floating point 56 | syn match goFloat contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" 57 | syn match goFloat contained "\<\.\d\+\([Ee][-+]\d\+\)\?\>" 58 | syn match goFloat contained "\<\d\+[Ee][-+]\d\+\>" 59 | " Imaginary literals 60 | syn match goImaginary contained "\<\d\+i\>" 61 | syn match goImaginary contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" 62 | syn match goImaginary contained "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" 63 | syn match goImaginary contained "\<\d\+[Ee][-+]\d\+i\>" 64 | 65 | hi def link goInt Number 66 | hi def link goFloat Number 67 | hi def link goImaginary Number 68 | 69 | " Token groups 70 | syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary 71 | syn keyword gotplControl contained if else end range with template include tpl required define 72 | syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge 73 | syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert bcrypt camelcase cat ceil clean coalesce \contains compact chunk date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div dig deepCopy decryptAES encryptAES env expandenv empty ext fail first float64 floor fromJson fromYaml genCA genCAWithKey genPrivateKey genSelfSignedCert genSelfSignedCertWithKey genSignedCert genSignedCertWithKey getHostByName has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone htpasswd indent initial initials int int64 isAbs join kebabcase keys kindIs kindOf last list lower max merge mergeOverwrite min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric randBytes regexFind regexFindAll regexMatch regexReplaceAll regexReplaceAllLiteral regexSplit repeat replace rest reverse round semver semverCompare set sha1sum sha256sum shuffle slice snakecase sortAlpha split splitList splitn squote sub substr swapcase ternary title toDate toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trimall trunc tuple typeIs typeIsLike typeOf uniq unixEpoch unset until untilStep untitle upper uuidv4 values without wrap wrapWith 74 | syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ 75 | syn match goTplIdentifier contained /\.[^\s}]+\>/ 76 | 77 | hi def link gotplControl Keyword 78 | hi def link gotplFunctions Function 79 | hi def link goSprigFunctions Function 80 | hi def link goTplVariable Special 81 | 82 | syn region gotplAction start="{{\(-\? \)\?" end="\( -\?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display 83 | syn region gotplAction start="\[\[\(-\? \)\?" end="\( -\?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display 84 | syn region goTplComment start="{{\(-\? \)\?/\*" end="\*/\( -\?\)\?}}" display 85 | syn region goTplComment start="\[\[\(-\? \)\?/\*" end="\*/\( -\?\)\?\]\]" display 86 | 87 | hi def link gotplAction PreProc 88 | hi def link goTplComment Comment 89 | let b:current_syntax = "helm" 90 | 91 | " vim: sw=2 ts=2 et 92 | --------------------------------------------------------------------------------