nvim: improvements to filetype detection

This commit is contained in:
Fernando Schauenburg 2025-03-05 10:17:28 +01:00
parent 448513ad70
commit 734c012556

View file

@ -2,13 +2,23 @@ local M = {}
M.setup = function() M.setup = function()
vim.filetype.add { vim.filetype.add {
-- 1. The file path/name is checked first.
filename = {
["clang-format"] = "yaml",
editorconfig = "editorconfig",
},
-- 2. Patterns are checked second.
pattern = { pattern = {
["${HOME}/.ssh/config.d/.*"] = "sshconfig", ["${HOME}/.ssh/config.d/.*"] = "sshconfig",
[".*/ssh/config"] = "sshconfig",
-- Files in my dotfiles repository.
[".*/config/zsh/.*"] = "zsh",
[".*/git/config"] = "gitconfig", [".*/git/config"] = "gitconfig",
[".*gitconfig"] = "gitconfig", [".*/ssh/config"] = "sshconfig",
[".*/home/editorconfig"] = "editorconfig", },
[".*config/zsh/.*"] = "zsh", -- 3. Finally, the extension is checked.
extension = {
gitconfig = "gitconfig",
}, },
} }
end end