From 69a51170f9e0f7c21242c85e2feac6aa17adeb22 Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Sun, 19 May 2024 16:06:50 +0100 Subject: [PATCH] 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\ */}}