From 98288dac32414ae4f00db7f844189cf9e843af50 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 1 Feb 2018 01:38:56 +0100 Subject: [PATCH 01/25] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0c2f7b9..7481a3c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # vim-helm vim syntax for helm templates (yaml + gotmpl + sprig + custom) + +Enable syntax using a definition like this: +`autocmd BufRead,BufNewFile */templates/*.yaml set ft=helm` From 5ce35c1981372a567677cceed561cc72e1432525 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 1 Feb 2018 01:38:12 +0100 Subject: [PATCH 02/25] Add simple helm.vim syntax definition --- syntax/helm.vim | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 syntax/helm.vim diff --git a/syntax/helm.vim b/syntax/helm.vim new file mode 100644 index 0000000..3414e97 --- /dev/null +++ b/syntax/helm.vim @@ -0,0 +1,91 @@ +if exists("b:current_syntax") + finish +endif + +if !exists("main_syntax") + let main_syntax = 'yaml' +endif + +let b:current_syntax = '' +unlet b:current_syntax +runtime! syntax/yaml.vim + +let b:current_syntax = '' +unlet b:current_syntax +syntax include @Yaml syntax/yaml.vim + +syn case match + +" Go escapes +syn match goEscapeOctal display contained "\\[0-7]\{3}" +syn match goEscapeC display contained +\\[abfnrtv\\'"]+ +syn match goEscapeX display contained "\\x\x\{2}" +syn match goEscapeU display contained "\\u\x\{4}" +syn match goEscapeBigU display contained "\\U\x\{8}" +syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ + +hi def link goEscapeOctal goSpecialString +hi def link goEscapeC goSpecialString +hi def link goEscapeX goSpecialString +hi def link goEscapeU goSpecialString +hi def link goEscapeBigU goSpecialString +hi def link goSpecialString Special +hi def link goEscapeError Error + +" Strings and their contents +syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError +syn region goString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup +syn region goRawString contained start=+`+ end=+`+ + +hi def link goString String +hi def link goRawString String + +" Characters; their contents +syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU +syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup + +hi def link goCharacter Character + +" Integers +syn match goDecimalInt contained "\<\d\+\([Ee]\d\+\)\?\>" +syn match goHexadecimalInt contained "\<0x\x\+\>" +syn match goOctalInt contained "\<0\o\+\>" +syn match goOctalError contained "\<0\o*[89]\d*\>" +syn cluster goInt contains=goDecimalInt,goHexadecimalInt,goOctalInt +" Floating point +syn match goFloat contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" +syn match goFloat contained "\<\.\d\+\([Ee][-+]\d\+\)\?\>" +syn match goFloat contained "\<\d\+[Ee][-+]\d\+\>" +" Imaginary literals +syn match goImaginary contained "\<\d\+i\>" +syn match goImaginary contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary contained "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary contained "\<\d\+[Ee][-+]\d\+i\>" + +hi def link goInt Number +hi def link goFloat Number +hi def link goImaginary Number + +" Token groups +syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary +syn keyword gotplControl contained if else end range with template +syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge +syn keyword goSprigFunctions contained abbrev abbrevboth add add1 append atoi b64dec b64enc base biggest camelcase cat clean coalesce compact \contains date dateInZone dateModify default derivePassword dict dir div empty ext first float64 fromJson fromYaml genPrivateKey has hasKey hasPrefix hasSuffix htmlDate htmlDateInZone include indent initial initials int int64 isAbs join keys kindIs kindOf last list lower max min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric repeat replace required rest reverse set sha256sum shuffle snakecase sortAlpha split splitList squote sub substr swapcase title toJson toPrettyJson toString toStrings toToml toYaml tpl trim trimAll trimPrefix trimSuffix trunc tuple typeIs typeIsLike typeOf uniq unset until untilStep untitle upper without wrap wrapWith +syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ +syn match goTplIdentifier contained /\.[^\s}]+\>/ + +hi def link gotplControl Keyword +hi def link gotplFunctions Function +hi def link goSprigFunctions Function +hi def link goTplVariable Special + +syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display +syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display +syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display +syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display + +hi def link gotplAction PreProc +hi def link goTplComment Comment +let b:current_syntax = "helm" + +" vim: sw=2 ts=2 et From eb197a80dbac6ab2a0e9125340c175c151234f48 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 1 Feb 2018 15:27:25 +0100 Subject: [PATCH 03/25] Make 'include', 'required' and 'tpl' stand out more --- syntax/helm.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index 3414e97..f5c6333 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -68,9 +68,9 @@ hi def link goImaginary Number " Token groups syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary -syn keyword gotplControl contained if else end range with template +syn keyword gotplControl contained if else end range with template include tpl required syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge -syn keyword goSprigFunctions contained abbrev abbrevboth add add1 append atoi b64dec b64enc base biggest camelcase cat clean coalesce compact \contains date dateInZone dateModify default derivePassword dict dir div empty ext first float64 fromJson fromYaml genPrivateKey has hasKey hasPrefix hasSuffix htmlDate htmlDateInZone include indent initial initials int int64 isAbs join keys kindIs kindOf last list lower max min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric repeat replace required rest reverse set sha256sum shuffle snakecase sortAlpha split splitList squote sub substr swapcase title toJson toPrettyJson toString toStrings toToml toYaml tpl trim trimAll trimPrefix trimSuffix trunc tuple typeIs typeIsLike typeOf uniq unset until untilStep untitle upper without wrap wrapWith +syn keyword goSprigFunctions contained abbrev abbrevboth add add1 append atoi b64dec b64enc base biggest camelcase cat clean coalesce compact \contains date dateInZone dateModify default derivePassword dict dir div empty ext first float64 fromJson fromYaml genPrivateKey has hasKey hasPrefix hasSuffix htmlDate htmlDateInZone indent initial initials int int64 isAbs join keys kindIs kindOf last list lower max min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric repeat replace rest reverse set sha256sum shuffle snakecase sortAlpha split splitList squote sub substr swapcase title toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trunc tuple typeIs typeIsLike typeOf uniq unset until untilStep untitle upper without wrap wrapWith syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match goTplIdentifier contained /\.[^\s}]+\>/ From a30f3cb4bd9be1eae315606d467a5300ca167fc4 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 29 Mar 2018 14:51:20 +0200 Subject: [PATCH 04/25] Add *.tpl to supported files --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7481a3c..a04c86c 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ vim syntax for helm templates (yaml + gotmpl + sprig + custom) Enable syntax using a definition like this: -`autocmd BufRead,BufNewFile */templates/*.yaml set ft=helm` +```vim +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm` +``` From 22ffff7a98d3e836e6be595ec346df71b0b5e193 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 29 Mar 2018 14:51:32 +0200 Subject: [PATCH 05/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a04c86c..d851c47 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ vim syntax for helm templates (yaml + gotmpl + sprig + custom) Enable syntax using a definition like this: ```vim -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm` +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm ``` From ee07975c92e0341fca9d137480d26e2e85f7b1c0 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Thu, 29 Mar 2018 15:00:05 +0200 Subject: [PATCH 06/25] Add missing tpl action 'define' --- syntax/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index f5c6333..fd9e39a 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -68,7 +68,7 @@ hi def link goImaginary Number " Token groups syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary -syn keyword gotplControl contained if else end range with template include tpl required +syn keyword gotplControl contained if else end range with template include tpl required define syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge syn keyword goSprigFunctions contained abbrev abbrevboth add add1 append atoi b64dec b64enc base biggest camelcase cat clean coalesce compact \contains date dateInZone dateModify default derivePassword dict dir div empty ext first float64 fromJson fromYaml genPrivateKey has hasKey hasPrefix hasSuffix htmlDate htmlDateInZone indent initial initials int int64 isAbs join keys kindIs kindOf last list lower max min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric repeat replace rest reverse set sha256sum shuffle snakecase sortAlpha split splitList squote sub substr swapcase title toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trunc tuple typeIs typeIsLike typeOf uniq unset until untilStep untitle upper without wrap wrapWith syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ From 0136756aa9783ce60b48302c434c5bc4e5dd5bc5 Mon Sep 17 00:00:00 2001 From: theimpostor Date: Fri, 27 Apr 2018 10:12:07 -0500 Subject: [PATCH 07/25] Convert to plugin --- README.md | 5 +++-- ftdetect/helm.vim | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 ftdetect/helm.vim diff --git a/README.md b/README.md index d851c47..e2ee0f2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # vim-helm vim syntax for helm templates (yaml + gotmpl + sprig + custom) -Enable syntax using a definition like this: +Install via vundle: + ```vim -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm +Plugin 'theimpostor/helm-vim' ``` diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim new file mode 100644 index 0000000..9a502ac --- /dev/null +++ b/ftdetect/helm.vim @@ -0,0 +1 @@ +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm From 1bb6bb7a1d78fc38c76e7757e58bd8839ac9792c Mon Sep 17 00:00:00 2001 From: theimpostor Date: Fri, 27 Apr 2018 10:13:18 -0500 Subject: [PATCH 08/25] Fix plugin address --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2ee0f2..4daf942 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,5 @@ vim syntax for helm templates (yaml + gotmpl + sprig + custom) Install via vundle: ```vim -Plugin 'theimpostor/helm-vim' +Plugin 'towolf/helm-vim' ``` From a256ea3417fd1829ab33657500cefedb69cc555a Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Fri, 4 May 2018 22:24:46 +0200 Subject: [PATCH 09/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4daf942..1a38dcc 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,5 @@ vim syntax for helm templates (yaml + gotmpl + sprig + custom) Install via vundle: ```vim -Plugin 'towolf/helm-vim' +Plugin 'towolf/vim-helm' ``` From dc1f43c0e906b5eb60e6a00cc8c0529a0dee4601 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sun, 4 Aug 2019 12:28:20 +0200 Subject: [PATCH 10/25] Add new Sprig functions --- syntax/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index fd9e39a..dafc0d6 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -70,7 +70,7 @@ hi def link goImaginary Number syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary syn keyword gotplControl contained if else end range with template include tpl required define syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge -syn keyword goSprigFunctions contained abbrev abbrevboth add add1 append atoi b64dec b64enc base biggest camelcase cat clean coalesce compact \contains date dateInZone dateModify default derivePassword dict dir div empty ext first float64 fromJson fromYaml genPrivateKey has hasKey hasPrefix hasSuffix htmlDate htmlDateInZone indent initial initials int int64 isAbs join keys kindIs kindOf last list lower max min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric repeat replace rest reverse set sha256sum shuffle snakecase sortAlpha split splitList squote sub substr swapcase title toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trunc tuple typeIs typeIsLike typeOf uniq unset until untilStep untitle upper without wrap wrapWith +syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty env expandenv ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone 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 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 syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match goTplIdentifier contained /\.[^\s}]+\>/ From a60eebcb7a60ddf28062d955f4de2b476f4ab490 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sun, 4 Aug 2019 13:21:24 +0200 Subject: [PATCH 11/25] env and expandenv are blacklisted in Helm, remove them --- syntax/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index dafc0d6..73c4097 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -70,7 +70,7 @@ hi def link goImaginary Number syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary syn keyword gotplControl contained if else end range with template include tpl required define syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge -syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty env expandenv ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone 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 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 +syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone 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 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 syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match goTplIdentifier contained /\.[^\s}]+\>/ From 57ac49639c49bae02aff95d8e1379df63fee2e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Aym=C3=A0?= Date: Sat, 12 Oct 2019 19:03:28 +0200 Subject: [PATCH 12/25] add optional spaces and removes after token --- syntax/helm.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index 73c4097..c7c75de 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -79,10 +79,10 @@ hi def link gotplFunctions Function hi def link goSprigFunctions Function hi def link goTplVariable Special -syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display -syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display -syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display -syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display +syn region gotplAction start="{{\(-? \)\?" end="\( -?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display +syn region gotplAction start="\[\[\(-? \)\?" end="\( -?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display +syn region goTplComment start="{{\(-? \)\?/\*" end="\*/\( -?\)\?}}" display +syn region goTplComment start="\[\[\(-? \)\?/\*" end="\*/\( -?\)\?\]\]" display hi def link gotplAction PreProc hi def link goTplComment Comment From 3c6a637264816327748d69e903ecd1b63b6755b0 Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Fri, 26 Nov 2021 17:44:58 +0200 Subject: [PATCH 13/25] fix: introduce commentstring Resolves #10 --- ftdetect/helm.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index 9a502ac..988f3c5 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1 +1,4 @@ autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm + +" Use {{/* */}} as comments +autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 867235e507e5bad17cf29cf042fb88ac356f8e12 Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Fri, 26 Nov 2021 19:03:31 +0200 Subject: [PATCH 14/25] fix: add gotmpl for helm detection --- ftdetect/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index 988f3c5..d908769 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,4 +1,4 @@ -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl set ft=helm " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 167e0fc592a68eeca8af8618811a909eac9c6bfe Mon Sep 17 00:00:00 2001 From: Mario Valderrama Date: Mon, 13 Dec 2021 14:55:18 +0100 Subject: [PATCH 15/25] Add more sprig functions to keywords --- syntax/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index c7c75de..03c9962 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -70,7 +70,7 @@ hi def link goImaginary Number syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary syn keyword gotplControl contained if else end range with template include tpl required define syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge -syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone 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 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 +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 syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match goTplIdentifier contained /\.[^\s}]+\>/ From 0fa659e4a243bf4bad01a0faca5ea9bc319cf33e Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Fri, 14 Jan 2022 18:51:47 +0200 Subject: [PATCH 16/25] fix: detect helmfile.yaml --- ftdetect/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index d908769..628045d 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,4 +1,4 @@ -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl set ft=helm +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl,helmfile.yaml set ft=helm " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 209312a36e1dd9f8fe54169e18c204ec08fa6dd8 Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Mon, 22 Aug 2022 14:44:54 +0300 Subject: [PATCH 17/25] fix: extend helmfile support --- ftdetect/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index 628045d..32de6a1 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,4 +1,4 @@ -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl,helmfile.yaml set ft=helm +autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl,helmfile*.yaml set ft=helm " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 22b37cbe974eb850c50e35ed2c6dedd0bfc749c7 Mon Sep 17 00:00:00 2001 From: Richard Kraus Date: Sat, 5 Aug 2023 10:43:13 +0200 Subject: [PATCH 18/25] escape ? to fix chomping modifier detection --- syntax/helm.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/helm.vim b/syntax/helm.vim index 03c9962..1607b96 100644 --- a/syntax/helm.vim +++ b/syntax/helm.vim @@ -79,10 +79,10 @@ hi def link gotplFunctions Function hi def link goSprigFunctions Function hi def link goTplVariable Special -syn region gotplAction start="{{\(-? \)\?" end="\( -?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display -syn region gotplAction start="\[\[\(-? \)\?" end="\( -?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display -syn region goTplComment start="{{\(-? \)\?/\*" end="\*/\( -?\)\?}}" display -syn region goTplComment start="\[\[\(-? \)\?/\*" end="\*/\( -?\)\?\]\]" display +syn region gotplAction start="{{\(-\? \)\?" end="\( -\?\)\?}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display +syn region gotplAction start="\[\[\(-\? \)\?" end="\( -\?\)\?\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display +syn region goTplComment start="{{\(-\? \)\?/\*" end="\*/\( -\?\)\?}}" display +syn region goTplComment start="\[\[\(-\? \)\?/\*" end="\*/\( -\?\)\?\]\]" display hi def link gotplAction PreProc hi def link goTplComment Comment From ab1a663f975beea8b9a5a2211aa087d85d2d08bc Mon Sep 17 00:00:00 2001 From: siraphob-api Date: Mon, 5 Feb 2024 12:36:39 +0700 Subject: [PATCH 19/25] Add .yml pattern matching in ftdetect --- ftdetect/helm.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index 32de6a1..f3fefcf 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,4 +1,4 @@ -autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl,*.gotmpl,helmfile*.yaml set ft=helm +autocmd BufRead,BufNewFile */templates/*.{yaml,yml},*/templates/*.tpl,*.gotmpl,helmfile*.{yaml,yml} set ft=helm " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 69a51170f9e0f7c21242c85e2feac6aa17adeb22 Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Sun, 19 May 2024 16:06:50 +0100 Subject: [PATCH 20/25] fix: improve file detection This should fix #7 and #21 Signed-off-by: Luis Davim --- ftdetect/helm.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index f3fefcf..ff4bb54 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,4 +1,13 @@ -autocmd BufRead,BufNewFile */templates/*.{yaml,yml},*/templates/*.tpl,*.gotmpl,helmfile*.{yaml,yml} set ft=helm +function! s:isHelm() + let filepath = expand("%:p") + let filename = expand("%:t") + if filepath =~ '\v/(templates|charts)/.*\.(ya?ml|gotmpl|tpl|txt)$' | return 1 | en + if filename =~ '\v(helmfile).ya?ml' | return 1 | en + if !empty(findfile("Chart.yaml", expand('%:p:h').';')) | return 1 | en + return 0 +endfunction + +autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | en " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From 2b2f83a2ee3284154032914c6fb96dd2c18a255d Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Tue, 21 May 2024 21:53:16 +0100 Subject: [PATCH 21/25] fix: make ftdetect less gready This should fix #25 and #23 --- ftdetect/helm.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index ff4bb54..b2d3d87 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,9 +1,8 @@ function! s:isHelm() let filepath = expand("%:p") let filename = expand("%:t") - if filepath =~ '\v/(templates|charts)/.*\.(ya?ml|gotmpl|tpl|txt)$' | return 1 | en + if filepath =~ '\v/(templates)/.*\.(ya?ml|gotmpl|tpl|txt)$' | return 1 | en if filename =~ '\v(helmfile).ya?ml' | return 1 | en - if !empty(findfile("Chart.yaml", expand('%:p:h').';')) | return 1 | en return 0 endfunction From 20dcb862f770ddb42c4428ee4632181378365758 Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Fri, 31 May 2024 10:36:13 +0300 Subject: [PATCH 22/25] fix: detection of helmfile related files Resolves #27 Signed-off-by: Ievgenii Shepeliuk --- ftdetect/helm.vim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index b2d3d87..aafed5a 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,12 +1,21 @@ function! s:isHelm() let filepath = expand("%:p") + + " yaml/yml/tpl/txt inside templates dir + if filepath =~ '\v/(templates)/.*\.(ya?ml|tpl|txt)$' | return 1 | endif + let filename = expand("%:t") - if filepath =~ '\v/(templates)/.*\.(ya?ml|gotmpl|tpl|txt)$' | return 1 | en - if filename =~ '\v(helmfile).ya?ml' | return 1 | en + + " helmfile templated values + if filename =~ '\v.*\.gotmpl$' | return 1 | endif + + " helmfile.yaml / helmfile-my.yaml / helmfile_my.yaml etc + if filename =~ '\v(helmfile).*\.ya?ml$' | return 1 | endif + return 0 endfunction -autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | en +autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | endif " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From d3187cff847969bfba299d2c48081717e60052cb Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sat, 7 Jun 2025 22:49:30 +0200 Subject: [PATCH 23/25] feat: add yaml.helm-values filetype this filetype is used by https://github.com/mrjosh/helm-ls/ to support completion of values.yaml files in the newest version. It would be cool if the ft could be included here since a lot of users are using this plugin with helm-ls. --- ftdetect/helm.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index aafed5a..ba66b60 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -16,6 +16,7 @@ function! s:isHelm() endfunction autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | endif +autocmd BufRead,BufNewFile values*.yaml setfiletype yaml.helm-values " Use {{/* */}} as comments autocmd FileType helm setlocal commentstring={{/*\ %s\ */}} From ff8b70f41668518f459cc519b2b9edfb7bce8cf7 Mon Sep 17 00:00:00 2001 From: Tom Zaspel <40226087+tzabbi@users.noreply.github.com> Date: Tue, 9 Sep 2025 08:26:11 +0200 Subject: [PATCH 24/25] feat: check if Chart.yaml exists in partent of templates dir --- ftdetect/helm.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index ba66b60..d811292 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -1,8 +1,15 @@ function! s:isHelm() let filepath = expand("%:p") - " yaml/yml/tpl/txt inside templates dir - if filepath =~ '\v/(templates)/.*\.(ya?ml|tpl|txt)$' | return 1 | endif + " yaml/yml/tpl/txt inside templates or sub dirs + " Chart.yaml exsists in partent of templates dir + let templates_pos = stridx(filepath, '/templates/') + if templates_pos != -1 + let chart_root = strpart(filepath, 0, templates_pos) + if filereadable(chart_root . '/Chart.yaml') && filepath =~# '\v\.(ya?ml|tpl|txt)$' + return 1 + endif + endif let filename = expand("%:t") From fa4b4d43681ef1363226834e113825c9f5aee2d5 Mon Sep 17 00:00:00 2001 From: Tom Zaspel <40226087+tzabbi@users.noreply.github.com> Date: Wed, 10 Sep 2025 07:40:51 +0200 Subject: [PATCH 25/25] Update helm.vim --- ftdetect/helm.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ftdetect/helm.vim b/ftdetect/helm.vim index d811292..5af593a 100644 --- a/ftdetect/helm.vim +++ b/ftdetect/helm.vim @@ -22,7 +22,17 @@ function! s:isHelm() return 0 endfunction -autocmd BufRead,BufNewFile * if s:isHelm() | set ft=helm | endif +" create helper function for neovim compatibility +function! s:CheckAndSetHelmFT() + if s:isHelm() + set ft=helm + endif +endfunction + +" wait until vim/neovim filetype detection is done +autocmd FileType yaml,text,gotmpl call s:CheckAndSetHelmFT() + +autocmd BufRead,BufNewFile *.tpl call s:CheckAndSetHelmFT() autocmd BufRead,BufNewFile values*.yaml setfiletype yaml.helm-values " Use {{/* */}} as comments