vim.filetype.add { extension = { norg = 'norg', prg = 'vfp', nuon = 'nu', d2 = 'd2', gotmpl = 'gotmpl', mdx = 'markdown.mdx', shtml = 'shtml', superhtml = 'superhtml', tf = 'terraform', tofu = 'opentofu', tofuvars = 'opentofu-vars', service = 'systemd', socket = 'systemd', timer = 'systemd', target = 'systemd', mount = 'systemd', automount = 'systemd', path = 'systemd', }, pattern = { ['.*%.container'] = 'quadlet', -- podman quadlet units ['.*%.volume'] = 'quadlet', ['.*%.network'] = 'quadlet', ['.*%.pod'] = 'quadlet', ['.*%.kube'] = 'quadlet', ['.*/%.vscode/.*%.json'] = 'json5', -- These json files frequently have comments ['.*%.tftpl'] = function(path) -- 1. Strip the '.tftpl' from the end of the path local base_path = path:gsub('%.tftpl$', '') -- 2. Ask Neovim to match the filetype based on the new "fake" filename local matched_ft = vim.filetype.match({ filename = base_path }) -- 3. Return the match, or fallback to 'terraform' if it's just 'file.tftpl' return matched_ft or 'terraform' end, ['.*docker%-compose.*%.ya?ml'] = 'yaml.docker-compose', ['.*gitlab%-ci.*%.ya?ml'] = 'yaml.gitlab', ['.*values.*%.ya?ml'] = 'yaml.helm-values', README = 'markdown', TODO = 'markdown', COMMANDS = 'markdown', DEPENDENCIES = 'markdown', ROADMAP = 'markdown', }, }