parent
5aa08aef39
commit
199f40b0ea
4 changed files with 176 additions and 145 deletions
40
templates/nvim/lua/filetype.lua.j2
Normal file
40
templates/nvim/lua/filetype.lua.j2
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local ansible_keywords = {
|
||||
'hosts',
|
||||
'tasks',
|
||||
'vars',
|
||||
'vars_files',
|
||||
'vars_prompt',
|
||||
'handlers',
|
||||
'roles',
|
||||
'import_tasks',
|
||||
'import_playbook',
|
||||
'import_role',
|
||||
}
|
||||
|
||||
vim.filetype.add {
|
||||
pattern = {
|
||||
['playbook*.y(a?)ml'] = 'yaml.ansible',
|
||||
['site*.y(a?)ml'] = 'yaml.ansible',
|
||||
['inventory*.y(a?)ml'] = 'yaml.ansible',
|
||||
['task*.y(a?)ml'] = 'yaml.ansible',
|
||||
['requirement*.y(a?)ml'] = 'yaml.ansible',
|
||||
|
||||
|
||||
['.*/tasks/.*.y(a?)ml'] = 'yaml.ansible',
|
||||
['.*/vars/.*.y(a?)ml'] = 'yaml.ansible',
|
||||
['.*/playbooks/.*.y(a?)ml'] = 'yaml.ansible',
|
||||
|
||||
['*.ansible.y(a?)ml'] = 'yaml.ansible',
|
||||
|
||||
['.*.y(a?)ml'] = {
|
||||
function(path, bufnr)
|
||||
local content = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ''
|
||||
|
||||
for _, keyword in pairs(ansible_keywords) do
|
||||
local pattern = string.format('^- %s:', keyword)
|
||||
if content:match(pattern) then return 'yaml.ansible' end
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue