vim.filetype.add { extension = { norg = 'norg', prg = 'vfp', nuon = 'nu', d2 = 'd2', tf = 'terraform', }, pattern = { ['.*/%.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, README = 'markdown', TODO = 'markdown', COMMANDS = 'markdown', DEPENDENCIES = 'markdown', ROADMAP = 'markdown', }, }