fix: improve file detection

This should fix #7 and #21

Signed-off-by: Luis Davim <luis.davim@gmail.com>
This commit is contained in:
Luis Davim
2024-05-19 16:06:50 +01:00
parent 86cc6766db
commit 69a51170f9
+10 -1
View File
@@ -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\ */}}