ansible-vim
ansible-vim copied to clipboard
neovim, how to keep ft=ansible instead of ft=yaml.ansible (mising jinjaVarBlock)
I just upgraded to neovim, and using these options:
vim.api.nvim_create_autocmd({
"BufRead",
"BufNewFile"
}, {
pattern = {
"*/ansible/*.yml",
"*/tasks/*.yml",
},
callback = function()
vim.bo.filetype = "ansible"
end
})
-- ansible hosts
vim.api.nvim_create_autocmd({
"BufRead",
"BufNewFile"
}, {
pattern = {
"*/ansible/inventory/*",
"*/ansible/hosts-*"
},
callback = function()
local filepath = vim.fn.expand("%:p")
if filepath:match("%.yml$") then
vim.bo.filetype = "yaml.ansible_hosts"
else
vim.bo.filetype = "ansible_hosts"
end
end
})
For the LSP using ansiblels I use this:
["ansiblels"] = function()
lspconfig.ansiblels.setup({
filetypes = {
"ansible",
"yaml.ansible",
"yaml.ansible_hosts"
},
settings = {
ansible = {
validation = {
lint = {
arguments = "-c ~/.config/ansible-lint.yml"
}
}
}
}
})
But the plugin is always overwriting the setting filetype to yaml.ansible, I would like to use only filetype ansible for "*/tasks/*.yml", any idea how to do this?
How could this maybe be overwriting using the after dir?
If I add this to every file: # vim: set ft=ansible: works but I would like to prevent don't it.
The main problem that I have is that if I use yaml.ansible for an unknown reason I don't see the jinjaVarBlock
This is how I see it with ft=yaml.ansible
And I I use ft=ansible:
I notice that when using ft=yaml.ansible the :syn list is empty but when using only ft=ansible I get all the syntax groups