local root = vim.fn.expand("%:p:h") local function match_ansible(path, bufnr) if path:find(root, 1, true) ~= nil then return "yaml.ansible" end return vim.api.nvim_get_option_value("filetype", { buf = bufnr }) end vim.filetype.add({ extension = { yaml = match_ansible, yml = match_ansible, }, })