fix autoformat

This commit is contained in:
Christian Nieves
2024-12-12 16:28:41 +00:00
parent ce6295b69a
commit 38f84a6dd9
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,29 @@
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
group = vim.api.nvim_create_augroup('gotmpl_highlight', { clear = true }),
pattern = '*.tmpl',
callback = function()
local filename = vim.fn.expand('%:t')
local ext = filename:match('.*%.(.-)%.tmpl$')
-- Add more extension to syntax mappings here if you need to.
local ext_filetypes = {
go = 'go',
html = 'html',
md = 'markdown',
yaml = 'yaml',
yml = 'yaml',
}
if ext and ext_filetypes[ext] then
-- Set the primary filetype
vim.bo.filetype = ext_filetypes[ext]
-- Define embedded Go template syntax
vim.cmd([[
syntax include @gotmpl syntax/gotmpl.vim
syntax region gotmpl start="{{" end="}}" contains=@gotmpl containedin=ALL
syntax region gotmpl start="{%" end="%}" contains=@gotmpl containedin=ALL
]])
end
end,
})