Vim syntax highlighting for Hugo HTML templates

Just as a side note:

As I only need the syntax and indentation for gohtmltmpl from vim-go (just two files) I use this simple script to detect the filetype:

function DetectGoHtmlTmpl()
    if expand('%:e') == "html" && search("{{") != 0
        set filetype=gohtmltmpl 
    endif
endfunction

augroup filetypedetect
    au! BufRead,BufNewFile * call DetectGoHtmlTmpl()
augroup END

Checks if file extension is html and if file contains search term {{

Maybe someone can use this.

7 Likes