I would like to have some intellisense/autocomplete for Go template files, but nothing I have tried has done anything. I have tried giving the files the .gotmpl
extension, I’ve looked up how to add filetypes to the gopls
server (I am using lsp-config), I have tried just sticking this autocommand in my lua config (I did edit it a little:
vim.api.nvim_create_autocmd(
{
"BufNewFile",
"BufRead",
},
{
pattern = "*.tmpl.html,*.tmpl.md,*.tmpl.yaml,*.tmpl.yml",
callback = function()
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_option(buf, "filetype", "gotmpl")
end
}
)
And I have even tried running :setlocal filetype=gotmpl
, which started the server, but there wasn’t any completion.
How can I have autocompletion for go template files?