21 lines
553 B
Lua
21 lines
553 B
Lua
-- Check file extension and set syntax highlighting
|
|
vim.cmd([[
|
|
augroup Jinja2Syntax
|
|
autocmd!
|
|
autocmd BufNewFile,BufRead *.j2 lua require('utils').set_jinja2_syntax()
|
|
augroup END
|
|
]])
|
|
|
|
-- Function to determine Jinja2 syntax highlighting
|
|
local function set_jinja2_syntax()
|
|
local file_extension = vim.fn.expand("%:e")
|
|
if file_extension == "j2" then
|
|
local base_filename = vim.fn.expand("%:r")
|
|
local base_filetype = vim.fn.fnamemodify(base_filename, ":t")
|
|
vim.opt.syntax = base_filetype
|
|
end
|
|
end
|
|
|
|
return {
|
|
set_jinja2_syntax = set_jinja2_syntax
|
|
}
|