mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
refactor(filetype): use file name match instead of pattern if possible
Problem: some patterns are used as a replacement for one-two explicit file matches (like '^[mM]akefile$'). As matching file name directly is faster and more explicit, it should be preferred. Solution: move those patterns to direct file name match. NOTE: this is not strictly backwards compatible, because exact file name matching is done *before* pattern matching. If user has conflicting `vim.filetype.add()` call with high priority (like with `pattern='file$'` and `priority=100`), after this change it will be ignored (i.e. 'makefile' will match exactly). Judging by converted cases, it seems reasonable to prefer exact matches there.
This commit is contained in:
parent
eb629cce91
commit
66a74535d4
@ -1332,7 +1332,17 @@ local filename = {
|
||||
['/.aptitude/config'] = 'aptconf',
|
||||
['=tagging-method'] = 'arch',
|
||||
['.arch-inventory'] = 'arch',
|
||||
['makefile.am'] = 'automake',
|
||||
['Makefile.am'] = 'automake',
|
||||
['GNUmakefile.am'] = 'automake',
|
||||
['.bash_aliases'] = detect.bash,
|
||||
['.bash-aliases'] = detect.bash,
|
||||
['.bash_history'] = detect.bash,
|
||||
['.bash-history'] = detect.bash,
|
||||
['.bash_logout'] = detect.bash,
|
||||
['.bash-logout'] = detect.bash,
|
||||
['.bash_profile'] = detect.bash,
|
||||
['.bash-profile'] = detect.bash,
|
||||
['named.root'] = 'bindzone',
|
||||
WORKSPACE = 'bzl',
|
||||
['WORKSPACE.bzlmod'] = 'bzl',
|
||||
@ -1507,6 +1517,8 @@ local filename = {
|
||||
['.swrc'] = 'jsonc',
|
||||
['.vsconfig'] = 'jsonc',
|
||||
['.justfile'] = 'just',
|
||||
['justfile'] = 'just',
|
||||
['Justfile'] = 'just',
|
||||
Kconfig = 'kconfig',
|
||||
['Kconfig.debug'] = 'kconfig',
|
||||
['Config.in'] = 'kconfig',
|
||||
@ -1558,6 +1570,8 @@ local filename = {
|
||||
mrxvtrc = 'mrxvtrc',
|
||||
['.mrxvtrc'] = 'mrxvtrc',
|
||||
['.msmtprc'] = 'msmtp',
|
||||
['Muttngrc'] = 'muttrc',
|
||||
['Muttrc'] = 'muttrc',
|
||||
['.mysql_history'] = 'mysql',
|
||||
['/etc/nanorc'] = 'nanorc',
|
||||
Neomuttrc = 'neomuttrc',
|
||||
@ -1582,6 +1596,9 @@ local filename = {
|
||||
['/etc/shadow-'] = 'passwd',
|
||||
['/etc/shadow'] = 'passwd',
|
||||
['/etc/passwd.edit'] = 'passwd',
|
||||
['.gitolite.rc'] = 'perl',
|
||||
['gitolite.rc'] = 'perl',
|
||||
['example.gitolite.rc'] = 'perl',
|
||||
['latexmkrc'] = 'perl',
|
||||
['.latexmkrc'] = 'perl',
|
||||
['pf.conf'] = 'pf',
|
||||
@ -1637,6 +1654,10 @@ local filename = {
|
||||
irbrc = 'ruby',
|
||||
['.irb_history'] = 'ruby',
|
||||
irb_history = 'ruby',
|
||||
['rakefile'] = 'ruby',
|
||||
['Rakefile'] = 'ruby',
|
||||
['rantfile'] = 'ruby',
|
||||
['Rantfile'] = 'ruby',
|
||||
Vagrantfile = 'ruby',
|
||||
['smb.conf'] = 'samba',
|
||||
screenrc = 'screen',
|
||||
@ -2074,13 +2095,6 @@ local pattern = {
|
||||
['%.git/info/exclude$'] = 'gitignore',
|
||||
['/%.config/git/ignore$'] = 'gitignore',
|
||||
},
|
||||
['bash'] = {
|
||||
['^%.bash[_%-]aliases$'] = detect.bash,
|
||||
['^%.bash[_%-]history$'] = detect.bash,
|
||||
['^%.bash[_%-]logout$'] = detect.bash,
|
||||
['^%.bash[_%-]profile$'] = detect.bash,
|
||||
['^bash%-fc[%-%.]'] = detect.bash,
|
||||
},
|
||||
['%.cfg'] = {
|
||||
['enlightenment/.*%.cfg$'] = 'c',
|
||||
['Eterm/.*%.cfg$'] = 'eterm',
|
||||
@ -2121,15 +2135,11 @@ local pattern = {
|
||||
['%.sst%.meta$'] = 'sisu',
|
||||
},
|
||||
['file'] = {
|
||||
['^[mM]akefile%.am$'] = 'automake',
|
||||
['^Containerfile%.'] = starsetf('dockerfile'),
|
||||
['^Dockerfile%.'] = starsetf('dockerfile'),
|
||||
['^[jJ]ustfile$'] = 'just',
|
||||
['[mM]akefile$'] = detect.make,
|
||||
['^[mM]akefile'] = starsetf('make'),
|
||||
['^[rR]akefile$'] = 'ruby',
|
||||
['^[rR]akefile'] = starsetf('ruby'),
|
||||
['^[rR]antfile$'] = 'ruby',
|
||||
['^%.profile'] = detect.sh,
|
||||
},
|
||||
['fvwm'] = {
|
||||
@ -2169,9 +2179,7 @@ local pattern = {
|
||||
['/%.mutt/muttrc'] = detect_muttrc,
|
||||
['/%.muttng/muttngrc'] = detect_muttrc,
|
||||
['/%.muttng/muttrc'] = detect_muttrc,
|
||||
['^Muttngrc$'] = 'muttrc',
|
||||
['^Muttngrc'] = detect_muttrc,
|
||||
['^Muttrc$'] = 'muttrc',
|
||||
['^Muttrc'] = detect_muttrc,
|
||||
-- neomuttrc* and .neomuttrc*
|
||||
['^%.?neomuttrc'] = detect_neomuttrc,
|
||||
@ -2195,6 +2203,7 @@ local pattern = {
|
||||
['%.vbproj%.user$'] = 'xml',
|
||||
},
|
||||
[''] = {
|
||||
['^bash%-fc[%-%.]'] = detect.bash,
|
||||
['/bind/db%.'] = starsetf('bindzone'),
|
||||
['/named/db%.'] = starsetf('bindzone'),
|
||||
['%.blade%.php$'] = 'blade',
|
||||
@ -2265,8 +2274,6 @@ local pattern = {
|
||||
['%.opam%.locked$'] = 'opam',
|
||||
['%.opam%.template$'] = 'opam',
|
||||
['%.[Oo][Pp][Ll]$'] = 'opl',
|
||||
['^%.?gitolite%.rc$'] = 'perl',
|
||||
['^example%.gitolite%.rc$'] = 'perl',
|
||||
['%.php%d$'] = 'php',
|
||||
['%.[Pp][Rr][Gg]$'] = detect.prg,
|
||||
['printcap'] = starsetf(function(path, bufnr)
|
||||
|
Loading…
Reference in New Issue
Block a user