mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06: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',
|
['/.aptitude/config'] = 'aptconf',
|
||||||
['=tagging-method'] = 'arch',
|
['=tagging-method'] = 'arch',
|
||||||
['.arch-inventory'] = 'arch',
|
['.arch-inventory'] = 'arch',
|
||||||
|
['makefile.am'] = 'automake',
|
||||||
|
['Makefile.am'] = 'automake',
|
||||||
['GNUmakefile.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',
|
['named.root'] = 'bindzone',
|
||||||
WORKSPACE = 'bzl',
|
WORKSPACE = 'bzl',
|
||||||
['WORKSPACE.bzlmod'] = 'bzl',
|
['WORKSPACE.bzlmod'] = 'bzl',
|
||||||
@ -1507,6 +1517,8 @@ local filename = {
|
|||||||
['.swrc'] = 'jsonc',
|
['.swrc'] = 'jsonc',
|
||||||
['.vsconfig'] = 'jsonc',
|
['.vsconfig'] = 'jsonc',
|
||||||
['.justfile'] = 'just',
|
['.justfile'] = 'just',
|
||||||
|
['justfile'] = 'just',
|
||||||
|
['Justfile'] = 'just',
|
||||||
Kconfig = 'kconfig',
|
Kconfig = 'kconfig',
|
||||||
['Kconfig.debug'] = 'kconfig',
|
['Kconfig.debug'] = 'kconfig',
|
||||||
['Config.in'] = 'kconfig',
|
['Config.in'] = 'kconfig',
|
||||||
@ -1558,6 +1570,8 @@ local filename = {
|
|||||||
mrxvtrc = 'mrxvtrc',
|
mrxvtrc = 'mrxvtrc',
|
||||||
['.mrxvtrc'] = 'mrxvtrc',
|
['.mrxvtrc'] = 'mrxvtrc',
|
||||||
['.msmtprc'] = 'msmtp',
|
['.msmtprc'] = 'msmtp',
|
||||||
|
['Muttngrc'] = 'muttrc',
|
||||||
|
['Muttrc'] = 'muttrc',
|
||||||
['.mysql_history'] = 'mysql',
|
['.mysql_history'] = 'mysql',
|
||||||
['/etc/nanorc'] = 'nanorc',
|
['/etc/nanorc'] = 'nanorc',
|
||||||
Neomuttrc = 'neomuttrc',
|
Neomuttrc = 'neomuttrc',
|
||||||
@ -1582,6 +1596,9 @@ local filename = {
|
|||||||
['/etc/shadow-'] = 'passwd',
|
['/etc/shadow-'] = 'passwd',
|
||||||
['/etc/shadow'] = 'passwd',
|
['/etc/shadow'] = 'passwd',
|
||||||
['/etc/passwd.edit'] = 'passwd',
|
['/etc/passwd.edit'] = 'passwd',
|
||||||
|
['.gitolite.rc'] = 'perl',
|
||||||
|
['gitolite.rc'] = 'perl',
|
||||||
|
['example.gitolite.rc'] = 'perl',
|
||||||
['latexmkrc'] = 'perl',
|
['latexmkrc'] = 'perl',
|
||||||
['.latexmkrc'] = 'perl',
|
['.latexmkrc'] = 'perl',
|
||||||
['pf.conf'] = 'pf',
|
['pf.conf'] = 'pf',
|
||||||
@ -1637,6 +1654,10 @@ local filename = {
|
|||||||
irbrc = 'ruby',
|
irbrc = 'ruby',
|
||||||
['.irb_history'] = 'ruby',
|
['.irb_history'] = 'ruby',
|
||||||
irb_history = 'ruby',
|
irb_history = 'ruby',
|
||||||
|
['rakefile'] = 'ruby',
|
||||||
|
['Rakefile'] = 'ruby',
|
||||||
|
['rantfile'] = 'ruby',
|
||||||
|
['Rantfile'] = 'ruby',
|
||||||
Vagrantfile = 'ruby',
|
Vagrantfile = 'ruby',
|
||||||
['smb.conf'] = 'samba',
|
['smb.conf'] = 'samba',
|
||||||
screenrc = 'screen',
|
screenrc = 'screen',
|
||||||
@ -2074,13 +2095,6 @@ local pattern = {
|
|||||||
['%.git/info/exclude$'] = 'gitignore',
|
['%.git/info/exclude$'] = 'gitignore',
|
||||||
['/%.config/git/ignore$'] = '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'] = {
|
['%.cfg'] = {
|
||||||
['enlightenment/.*%.cfg$'] = 'c',
|
['enlightenment/.*%.cfg$'] = 'c',
|
||||||
['Eterm/.*%.cfg$'] = 'eterm',
|
['Eterm/.*%.cfg$'] = 'eterm',
|
||||||
@ -2121,15 +2135,11 @@ local pattern = {
|
|||||||
['%.sst%.meta$'] = 'sisu',
|
['%.sst%.meta$'] = 'sisu',
|
||||||
},
|
},
|
||||||
['file'] = {
|
['file'] = {
|
||||||
['^[mM]akefile%.am$'] = 'automake',
|
|
||||||
['^Containerfile%.'] = starsetf('dockerfile'),
|
['^Containerfile%.'] = starsetf('dockerfile'),
|
||||||
['^Dockerfile%.'] = starsetf('dockerfile'),
|
['^Dockerfile%.'] = starsetf('dockerfile'),
|
||||||
['^[jJ]ustfile$'] = 'just',
|
|
||||||
['[mM]akefile$'] = detect.make,
|
['[mM]akefile$'] = detect.make,
|
||||||
['^[mM]akefile'] = starsetf('make'),
|
['^[mM]akefile'] = starsetf('make'),
|
||||||
['^[rR]akefile$'] = 'ruby',
|
|
||||||
['^[rR]akefile'] = starsetf('ruby'),
|
['^[rR]akefile'] = starsetf('ruby'),
|
||||||
['^[rR]antfile$'] = 'ruby',
|
|
||||||
['^%.profile'] = detect.sh,
|
['^%.profile'] = detect.sh,
|
||||||
},
|
},
|
||||||
['fvwm'] = {
|
['fvwm'] = {
|
||||||
@ -2169,9 +2179,7 @@ local pattern = {
|
|||||||
['/%.mutt/muttrc'] = detect_muttrc,
|
['/%.mutt/muttrc'] = detect_muttrc,
|
||||||
['/%.muttng/muttngrc'] = detect_muttrc,
|
['/%.muttng/muttngrc'] = detect_muttrc,
|
||||||
['/%.muttng/muttrc'] = detect_muttrc,
|
['/%.muttng/muttrc'] = detect_muttrc,
|
||||||
['^Muttngrc$'] = 'muttrc',
|
|
||||||
['^Muttngrc'] = detect_muttrc,
|
['^Muttngrc'] = detect_muttrc,
|
||||||
['^Muttrc$'] = 'muttrc',
|
|
||||||
['^Muttrc'] = detect_muttrc,
|
['^Muttrc'] = detect_muttrc,
|
||||||
-- neomuttrc* and .neomuttrc*
|
-- neomuttrc* and .neomuttrc*
|
||||||
['^%.?neomuttrc'] = detect_neomuttrc,
|
['^%.?neomuttrc'] = detect_neomuttrc,
|
||||||
@ -2195,6 +2203,7 @@ local pattern = {
|
|||||||
['%.vbproj%.user$'] = 'xml',
|
['%.vbproj%.user$'] = 'xml',
|
||||||
},
|
},
|
||||||
[''] = {
|
[''] = {
|
||||||
|
['^bash%-fc[%-%.]'] = detect.bash,
|
||||||
['/bind/db%.'] = starsetf('bindzone'),
|
['/bind/db%.'] = starsetf('bindzone'),
|
||||||
['/named/db%.'] = starsetf('bindzone'),
|
['/named/db%.'] = starsetf('bindzone'),
|
||||||
['%.blade%.php$'] = 'blade',
|
['%.blade%.php$'] = 'blade',
|
||||||
@ -2265,8 +2274,6 @@ local pattern = {
|
|||||||
['%.opam%.locked$'] = 'opam',
|
['%.opam%.locked$'] = 'opam',
|
||||||
['%.opam%.template$'] = 'opam',
|
['%.opam%.template$'] = 'opam',
|
||||||
['%.[Oo][Pp][Ll]$'] = 'opl',
|
['%.[Oo][Pp][Ll]$'] = 'opl',
|
||||||
['^%.?gitolite%.rc$'] = 'perl',
|
|
||||||
['^example%.gitolite%.rc$'] = 'perl',
|
|
||||||
['%.php%d$'] = 'php',
|
['%.php%d$'] = 'php',
|
||||||
['%.[Pp][Rr][Gg]$'] = detect.prg,
|
['%.[Pp][Rr][Gg]$'] = detect.prg,
|
||||||
['printcap'] = starsetf(function(path, bufnr)
|
['printcap'] = starsetf(function(path, bufnr)
|
||||||
|
Loading…
Reference in New Issue
Block a user