fix autoformat
This commit is contained in:
29
vim/.vim/lua/config/tmpl.lua
Normal file
29
vim/.vim/lua/config/tmpl.lua
Normal 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,
|
||||
})
|
Reference in New Issue
Block a user