refactor(filetype): use Lua patterns without implicit anchoring

This commit is contained in:
Evgeni Chasnovski
2024-07-12 15:53:57 +03:00
parent 9d14b76089
commit 708b5f86ba

View File

@@ -1730,484 +1730,487 @@ local detect_apache = starsetf('apache')
local detect_muttrc = starsetf('muttrc') local detect_muttrc = starsetf('muttrc')
local detect_neomuttrc = starsetf('neomuttrc') local detect_neomuttrc = starsetf('neomuttrc')
--- Vim regexes are converted into explicit Lua patterns (without implicit anchoring):
--- '*/debian/changelog' -> '/debian/changelog$'
--- '*/bind/db.*' -> '/bind/db%.'
--- @type vim.filetype.mapping --- @type vim.filetype.mapping
local pattern = { local pattern = {
-- BEGIN PATTERN -- BEGIN PATTERN
['.*/etc/a2ps/.*%.cfg'] = 'a2ps', ['/etc/a2ps/.*%.cfg$'] = 'a2ps',
['.*/etc/a2ps%.cfg'] = 'a2ps', ['/etc/a2ps%.cfg$'] = 'a2ps',
['.*/usr/share/alsa/alsa%.conf'] = 'alsaconf', ['/usr/share/alsa/alsa%.conf$'] = 'alsaconf',
['.*/etc/asound%.conf'] = 'alsaconf', ['/etc/asound%.conf$'] = 'alsaconf',
['.*/etc/apache2/sites%-.*/.*%.com'] = 'apache', ['/etc/apache2/sites%-.*/.*%.com$'] = 'apache',
['.*/etc/httpd/.*%.conf'] = 'apache', ['/etc/httpd/.*%.conf$'] = 'apache',
['.*/etc/apache2/.*%.conf.*'] = detect_apache, ['/etc/apache2/.*%.conf'] = detect_apache,
['.*/etc/apache2/conf%..*/.*'] = detect_apache, ['/etc/apache2/conf%..*/'] = detect_apache,
['.*/etc/apache2/mods%-.*/.*'] = detect_apache, ['/etc/apache2/mods%-.*/'] = detect_apache,
['.*/etc/apache2/sites%-.*/.*'] = detect_apache, ['/etc/apache2/sites%-.*/'] = detect_apache,
['access%.conf.*'] = detect_apache, ['^access%.conf'] = detect_apache,
['apache%.conf.*'] = detect_apache, ['^apache%.conf'] = detect_apache,
['apache2%.conf.*'] = detect_apache, ['^apache2%.conf'] = detect_apache,
['httpd%.conf.*'] = detect_apache, ['^httpd%.conf'] = detect_apache,
['srm%.conf.*'] = detect_apache, ['^srm%.conf'] = detect_apache,
['.*/etc/httpd/conf%..*/.*'] = detect_apache, ['/etc/httpd/conf%..*/'] = detect_apache,
['.*/etc/httpd/conf%.d/.*%.conf.*'] = detect_apache, ['/etc/httpd/conf%.d/.*%.conf'] = detect_apache,
['.*/etc/httpd/mods%-.*/.*'] = detect_apache, ['/etc/httpd/mods%-.*/'] = detect_apache,
['.*/etc/httpd/sites%-.*/.*'] = detect_apache, ['/etc/httpd/sites%-.*/'] = detect_apache,
['.*/etc/proftpd/.*%.conf.*'] = starsetf('apachestyle'), ['/etc/proftpd/.*%.conf'] = starsetf('apachestyle'),
['.*/etc/proftpd/conf%..*/.*'] = starsetf('apachestyle'), ['/etc/proftpd/conf%..*/'] = starsetf('apachestyle'),
['proftpd%.conf.*'] = starsetf('apachestyle'), ['^proftpd%.conf'] = starsetf('apachestyle'),
['.*asterisk/.*%.conf.*'] = starsetf('asterisk'), ['asterisk/.*%.conf'] = starsetf('asterisk'),
['.*asterisk.*/.*voicemail%.conf.*'] = starsetf('asteriskvm'), ['asterisk.*/.*voicemail%.conf'] = starsetf('asteriskvm'),
['.*/%.aptitude/config'] = 'aptconf', ['/%.aptitude/config$'] = 'aptconf',
['[mM]akefile%.am'] = 'automake', ['^[mM]akefile%.am$'] = 'automake',
['.*/bind/db%..*'] = starsetf('bindzone'), ['/bind/db%.'] = starsetf('bindzone'),
['.*/named/db%..*'] = starsetf('bindzone'), ['/named/db%.'] = starsetf('bindzone'),
['.*/build/conf/.*%.conf'] = 'bitbake', ['/build/conf/.*%.conf$'] = 'bitbake',
['.*/meta/conf/.*%.conf'] = 'bitbake', ['/meta/conf/.*%.conf$'] = 'bitbake',
['.*/meta%-.*/conf/.*%.conf'] = 'bitbake', ['/meta%-.*/conf/.*%.conf$'] = 'bitbake',
['.*%.blade%.php'] = 'blade', ['%.blade%.php$'] = 'blade',
['bzr_log%..*'] = 'bzr', ['^bzr_log%.'] = 'bzr',
['.*enlightenment/.*%.cfg'] = 'c', ['enlightenment/.*%.cfg$'] = 'c',
['.*/%.cabal/config'] = 'cabalconfig', ['/%.cabal/config$'] = 'cabalconfig',
['.*/cabal/config'] = 'cabalconfig', ['/cabal/config$'] = 'cabalconfig',
['cabal%.project%..*'] = starsetf('cabalproject'), ['^cabal%.project%.'] = starsetf('cabalproject'),
['.*/%.calendar/.*'] = starsetf('calendar'), ['/%.calendar/'] = starsetf('calendar'),
['.*/share/calendar/.*/calendar%..*'] = starsetf('calendar'), ['/share/calendar/.*/calendar%.'] = starsetf('calendar'),
['.*/share/calendar/calendar%..*'] = starsetf('calendar'), ['/share/calendar/calendar%.'] = starsetf('calendar'),
['sgml%.catalog.*'] = starsetf('catalog'), ['^sgml%.catalog'] = starsetf('catalog'),
['.*/etc/defaults/cdrdao'] = 'cdrdaoconf', ['/etc/defaults/cdrdao$'] = 'cdrdaoconf',
['.*/etc/cdrdao%.conf'] = 'cdrdaoconf', ['/etc/cdrdao%.conf$'] = 'cdrdaoconf',
['.*/etc/default/cdrdao'] = 'cdrdaoconf', ['/etc/default/cdrdao$'] = 'cdrdaoconf',
['.*hgrc'] = 'cfg', ['hgrc$'] = 'cfg',
['.*%.[Cc][Ff][Gg]'] = { ['%.[Cc][Ff][Gg]$'] = {
detect.cfg, detect.cfg,
-- Decrease priority to avoid conflicts with more specific patterns -- Decrease priority to avoid conflicts with more specific patterns
-- such as '.*/etc/a2ps/.*%.cfg', '.*enlightenment/.*%.cfg', etc. -- such as '.*/etc/a2ps/.*%.cfg', '.*enlightenment/.*%.cfg', etc.
{ priority = -1 }, { priority = -1 },
}, },
['[cC]hange[lL]og.*'] = starsetf(detect.changelog), ['^[cC]hange[lL]og'] = starsetf(detect.changelog),
['.*%.%.ch'] = 'chill', ['%.%.ch$'] = 'chill',
['.*/etc/translate%-shell'] = 'clojure', ['/etc/translate%-shell$'] = 'clojure',
['.*%.cmake%.in'] = 'cmake', ['%.cmake%.in$'] = 'cmake',
-- */cmus/rc and */.cmus/rc -- */cmus/rc and */.cmus/rc
['.*/%.?cmus/rc'] = 'cmusrc', ['/%.?cmus/rc$'] = 'cmusrc',
-- */cmus/*.theme and */.cmus/*.theme -- */cmus/*.theme and */.cmus/*.theme
['.*/%.?cmus/.*%.theme'] = 'cmusrc', ['/%.?cmus/.*%.theme$'] = 'cmusrc',
['.*/%.cmus/autosave'] = 'cmusrc', ['/%.cmus/autosave$'] = 'cmusrc',
['.*/%.cmus/command%-history'] = 'cmusrc', ['/%.cmus/command%-history$'] = 'cmusrc',
['.*/etc/hostname%..*'] = starsetf('config'), ['/etc/hostname%.'] = starsetf('config'),
['crontab%..*'] = starsetf('crontab'), ['^crontab%.'] = starsetf('crontab'),
['.*/etc/cron%.d/.*'] = starsetf('crontab'), ['/etc/cron%.d/'] = starsetf('crontab'),
['%.cshrc.*'] = detect.csh, ['^%.cshrc'] = detect.csh,
['%.login.*'] = detect.csh, ['^%.login'] = detect.csh,
['cvs%d+'] = 'cvs', ['^cvs%d+$'] = 'cvs',
['.*%.[Dd][Aa][Tt]'] = detect.dat, ['%.[Dd][Aa][Tt]$'] = detect.dat,
['.*/debian/patches/.*'] = detect.dep3patch, ['/debian/patches/'] = detect.dep3patch,
['.*/etc/dnsmasq%.d/.*'] = starsetf('dnsmasq'), ['/etc/dnsmasq%.d/'] = starsetf('dnsmasq'),
['Containerfile%..*'] = starsetf('dockerfile'), ['^Containerfile%.'] = starsetf('dockerfile'),
['Dockerfile%..*'] = starsetf('dockerfile'), ['^Dockerfile%.'] = starsetf('dockerfile'),
['.*/etc/yum%.repos%.d/.*'] = starsetf('dosini'), ['/etc/yum%.repos%.d/'] = starsetf('dosini'),
['drac%..*'] = starsetf('dracula'), ['^drac%.'] = starsetf('dracula'),
['.*/debian/changelog'] = 'debchangelog', ['/debian/changelog$'] = 'debchangelog',
['.*/debian/control'] = 'debcontrol', ['/debian/control$'] = 'debcontrol',
['.*/debian/copyright'] = 'debcopyright', ['/debian/copyright$'] = 'debcopyright',
['.*/etc/apt/sources%.list%.d/.*%.list'] = 'debsources', ['/etc/apt/sources%.list%.d/.*%.list$'] = 'debsources',
['.*/etc/apt/sources%.list'] = 'debsources', ['/etc/apt/sources%.list$'] = 'debsources',
['.*/etc/apt/sources%.list%.d/.*%.sources'] = 'deb822sources', ['/etc/apt/sources%.list%.d/.*%.sources$'] = 'deb822sources',
['dictd.*%.conf'] = 'dictdconf', ['^dictd.*%.conf$'] = 'dictdconf',
['.*/etc/DIR_COLORS'] = 'dircolors', ['/etc/DIR_COLORS$'] = 'dircolors',
['.*/etc/dnsmasq%.conf'] = 'dnsmasq', ['/etc/dnsmasq%.conf$'] = 'dnsmasq',
['php%.ini%-.*'] = 'dosini', ['^php%.ini%-'] = 'dosini',
['.*/%.aws/config'] = 'confini', ['/%.aws/config$'] = 'confini',
['.*/%.aws/credentials'] = 'confini', ['/%.aws/credentials$'] = 'confini',
['.*/etc/yum%.conf'] = 'dosini', ['/etc/yum%.conf$'] = 'dosini',
['.*/lxqt/.*%.conf'] = 'dosini', ['/lxqt/.*%.conf$'] = 'dosini',
['.*/screengrab/.*%.conf'] = 'dosini', ['/screengrab/.*%.conf$'] = 'dosini',
['.*/bpython/config'] = 'dosini', ['/bpython/config$'] = 'dosini',
['.*/mypy/config'] = 'dosini', ['/mypy/config$'] = 'dosini',
['.*/flatpak/repo/config'] = 'dosini', ['/flatpak/repo/config$'] = 'dosini',
['.*lvs'] = 'dracula', ['lvs$'] = 'dracula',
['.*lpe'] = 'dracula', ['lpe$'] = 'dracula',
['.*/dtrace/.*%.d'] = 'dtrace', ['/dtrace/.*%.d$'] = 'dtrace',
['.*esmtprc'] = 'esmtprc', ['esmtprc$'] = 'esmtprc',
['.*Eterm/.*%.cfg'] = 'eterm', ['Eterm/.*%.cfg$'] = 'eterm',
['.*s6.*/up'] = 'execline', ['s6.*/up$'] = 'execline',
['.*s6.*/down'] = 'execline', ['s6.*/down$'] = 'execline',
['.*s6.*/run'] = 'execline', ['s6.*/run$'] = 'execline',
['.*s6.*/finish'] = 'execline', ['s6.*/finish$'] = 'execline',
['s6%-.*'] = 'execline', ['^s6%-'] = 'execline',
['[a-zA-Z0-9].*Dict'] = detect.foam, ['^[a-zA-Z0-9].*Dict$'] = detect.foam,
['[a-zA-Z0-9].*Dict%..*'] = detect.foam, ['^[a-zA-Z0-9].*Dict%.'] = detect.foam,
['[a-zA-Z].*Properties'] = detect.foam, ['^[a-zA-Z].*Properties$'] = detect.foam,
['[a-zA-Z].*Properties%..*'] = detect.foam, ['^[a-zA-Z].*Properties%.'] = detect.foam,
['.*Transport%..*'] = detect.foam, ['Transport%.'] = detect.foam,
['.*/constant/g'] = detect.foam, ['/constant/g$'] = detect.foam,
['.*/0/.*'] = detect.foam, ['/0/'] = detect.foam,
['.*/0%.orig/.*'] = detect.foam, ['/0%.orig/'] = detect.foam,
['.*/%.fvwm/.*'] = starsetf('fvwm'), ['/%.fvwm/'] = starsetf('fvwm'),
['.*fvwmrc.*'] = starsetf(detect.fvwm_v1), ['fvwmrc'] = starsetf(detect.fvwm_v1),
['.*fvwm95.*%.hook'] = starsetf(detect.fvwm_v1), ['fvwm95.*%.hook$'] = starsetf(detect.fvwm_v1),
['.*fvwm2rc.*'] = starsetf(detect.fvwm_v2), ['fvwm2rc'] = starsetf(detect.fvwm_v2),
['.*/tmp/lltmp.*'] = starsetf('gedcom'), ['/tmp/lltmp'] = starsetf('gedcom'),
['.*/etc/gitconfig%.d/.*'] = starsetf('gitconfig'), ['/etc/gitconfig%.d/'] = starsetf('gitconfig'),
['.*/gitolite%-admin/conf/.*'] = starsetf('gitolite'), ['/gitolite%-admin/conf/'] = starsetf('gitolite'),
['tmac%..*'] = starsetf('nroff'), ['^tmac%.'] = starsetf('nroff'),
['.*/%.gitconfig%.d/.*'] = starsetf('gitconfig'), ['/%.gitconfig%.d/'] = starsetf('gitconfig'),
['.*%.git/.*'] = { ['%.git/'] = {
detect.git, detect.git,
-- Decrease priority to run after simple pattern checks -- Decrease priority to run after simple pattern checks
{ priority = -1 }, { priority = -1 },
}, },
['.*%.git/modules/.*/config'] = 'gitconfig', ['%.git/modules/.*/config$'] = 'gitconfig',
['.*%.git/modules/config'] = 'gitconfig', ['%.git/modules/config$'] = 'gitconfig',
['.*%.git/config'] = 'gitconfig', ['%.git/config$'] = 'gitconfig',
['.*/etc/gitconfig'] = 'gitconfig', ['/etc/gitconfig$'] = 'gitconfig',
['.*/%.config/git/config'] = 'gitconfig', ['/%.config/git/config$'] = 'gitconfig',
['.*%.git/config%.worktree'] = 'gitconfig', ['%.git/config%.worktree$'] = 'gitconfig',
['.*%.git/worktrees/.*/config%.worktree'] = 'gitconfig', ['%.git/worktrees/.*/config%.worktree$'] = 'gitconfig',
['${XDG_CONFIG_HOME}/git/config'] = 'gitconfig', ['^${XDG_CONFIG_HOME}/git/config$'] = 'gitconfig',
['.*%.git/info/attributes'] = 'gitattributes', ['%.git/info/attributes$'] = 'gitattributes',
['.*/etc/gitattributes'] = 'gitattributes', ['/etc/gitattributes$'] = 'gitattributes',
['.*/%.config/git/attributes'] = 'gitattributes', ['/%.config/git/attributes$'] = 'gitattributes',
['${XDG_CONFIG_HOME}/git/attributes'] = 'gitattributes', ['^${XDG_CONFIG_HOME}/git/attributes$'] = 'gitattributes',
['.*%.git/info/exclude'] = 'gitignore', ['%.git/info/exclude$'] = 'gitignore',
['.*/%.config/git/ignore'] = 'gitignore', ['/%.config/git/ignore$'] = 'gitignore',
['${XDG_CONFIG_HOME}/git/ignore'] = 'gitignore', ['^${XDG_CONFIG_HOME}/git/ignore$'] = 'gitignore',
['%.gitsendemail%.msg%.......'] = 'gitsendemail', ['^%.gitsendemail%.msg%.......$'] = 'gitsendemail',
['gkrellmrc_.'] = 'gkrellmrc', ['^gkrellmrc_.$'] = 'gkrellmrc',
['.*/usr/.*/gnupg/options%.skel'] = 'gpg', ['/usr/.*/gnupg/options%.skel$'] = 'gpg',
['.*/%.gnupg/options'] = 'gpg', ['/%.gnupg/options$'] = 'gpg',
['.*/%.gnupg/gpg%.conf'] = 'gpg', ['/%.gnupg/gpg%.conf$'] = 'gpg',
['${GNUPGHOME}/options'] = 'gpg', ['^${GNUPGHOME}/options$'] = 'gpg',
['${GNUPGHOME}/gpg%.conf'] = 'gpg', ['^${GNUPGHOME}/gpg%.conf$'] = 'gpg',
['.*/etc/group'] = 'group', ['/etc/group$'] = 'group',
['.*/etc/gshadow'] = 'group', ['/etc/gshadow$'] = 'group',
['.*/etc/group%.edit'] = 'group', ['/etc/group%.edit$'] = 'group',
['.*/var/backups/gshadow%.bak'] = 'group', ['/var/backups/gshadow%.bak$'] = 'group',
['.*/etc/group%-'] = 'group', ['/etc/group%-$'] = 'group',
['.*/etc/gshadow%-'] = 'group', ['/etc/gshadow%-$'] = 'group',
['.*/var/backups/group%.bak'] = 'group', ['/var/backups/group%.bak$'] = 'group',
['.*/etc/gshadow%.edit'] = 'group', ['/etc/gshadow%.edit$'] = 'group',
['.*/boot/grub/grub%.conf'] = 'grub', ['/boot/grub/grub%.conf$'] = 'grub',
['.*/boot/grub/menu%.lst'] = 'grub', ['/boot/grub/menu%.lst$'] = 'grub',
['.*/etc/grub%.conf'] = 'grub', ['/etc/grub%.conf$'] = 'grub',
-- gtkrc* and .gtkrc* -- gtkrc* and .gtkrc*
['%.?gtkrc.*'] = starsetf('gtkrc'), ['^%.?gtkrc'] = starsetf('gtkrc'),
['${VIMRUNTIME}/doc/.*%.txt'] = 'help', ['^${VIMRUNTIME}/doc/.*%.txt$'] = 'help',
['hg%-editor%-.*%.txt'] = 'hgcommit', ['^hg%-editor%-.*%.txt$'] = 'hgcommit',
['.*/etc/host%.conf'] = 'hostconf', ['/etc/host%.conf$'] = 'hostconf',
['.*/etc/hosts%.deny'] = 'hostsaccess', ['/etc/hosts%.deny$'] = 'hostsaccess',
['.*/etc/hosts%.allow'] = 'hostsaccess', ['/etc/hosts%.allow$'] = 'hostsaccess',
['.*%.html%.m4'] = 'htmlm4', ['%.html%.m4$'] = 'htmlm4',
['.*/%.i3/config'] = 'i3config', ['/%.i3/config$'] = 'i3config',
['.*/i3/config'] = 'i3config', ['/i3/config$'] = 'i3config',
['.*/%.icewm/menu'] = 'icemenu', ['/%.icewm/menu$'] = 'icemenu',
['.*/etc/initng/.*/.*%.i'] = 'initng', ['/etc/initng/.*/.*%.i$'] = 'initng',
['JAM.*%..*'] = starsetf('jam'), ['^JAM.*%.'] = starsetf('jam'),
['Prl.*%..*'] = starsetf('jam'), ['^Prl.*%.'] = starsetf('jam'),
['.*%.properties_..'] = 'jproperties', ['%.properties_..$'] = 'jproperties',
['.*%.properties_.._..'] = 'jproperties', ['%.properties_.._..$'] = 'jproperties',
['org%.eclipse%..*%.prefs'] = 'jproperties', ['^org%.eclipse%..*%.prefs$'] = 'jproperties',
['.*%.properties_.._.._.*'] = starsetf('jproperties'), ['%.properties_.._.._'] = starsetf('jproperties'),
['[jt]sconfig.*%.json'] = 'jsonc', ['^[jt]sconfig.*%.json$'] = 'jsonc',
['[jJ]ustfile'] = 'just', ['^[jJ]ustfile$'] = 'just',
['Kconfig%..*'] = starsetf('kconfig'), ['^Kconfig%.'] = starsetf('kconfig'),
['Config%.in%..*'] = starsetf('kconfig'), ['^Config%.in%.'] = starsetf('kconfig'),
['.*%.[Ss][Uu][Bb]'] = 'krl', ['%.[Ss][Uu][Bb]$'] = 'krl',
['lilo%.conf.*'] = starsetf('lilo'), ['^lilo%.conf'] = starsetf('lilo'),
['.*/etc/logcheck/.*%.d.*/.*'] = starsetf('logcheck'), ['/etc/logcheck/.*%.d.*/'] = starsetf('logcheck'),
['.*/ldscripts/.*'] = 'ld', ['/ldscripts/'] = 'ld',
['.*lftp/rc'] = 'lftp', ['lftp/rc$'] = 'lftp',
['.*/%.libao'] = 'libao', ['/%.libao$'] = 'libao',
['.*/etc/libao%.conf'] = 'libao', ['/etc/libao%.conf$'] = 'libao',
['.*/etc/.*limits%.conf'] = 'limits', ['/etc/.*limits%.conf$'] = 'limits',
['.*/etc/limits'] = 'limits', ['/etc/limits$'] = 'limits',
['.*/etc/.*limits%.d/.*%.conf'] = 'limits', ['/etc/.*limits%.d/.*%.conf$'] = 'limits',
['.*/supertux2/config'] = 'lisp', ['/supertux2/config$'] = 'lisp',
['.*/LiteStep/.*/.*%.rc'] = 'litestep', ['/LiteStep/.*/.*%.rc$'] = 'litestep',
['.*/etc/login%.access'] = 'loginaccess', ['/etc/login%.access$'] = 'loginaccess',
['.*/etc/login%.defs'] = 'logindefs', ['/etc/login%.defs$'] = 'logindefs',
['%.letter%.%d+'] = 'mail', ['^%.letter%.%d+$'] = 'mail',
['%.article%.%d+'] = 'mail', ['^%.article%.%d+$'] = 'mail',
['/tmp/SLRN[0-9A-Z.]+'] = 'mail', ['^/tmp/SLRN[0-9A-Z.]+$'] = 'mail',
['ae%d+%.txt'] = 'mail', ['^ae%d+%.txt$'] = 'mail',
['pico%.%d+'] = 'mail', ['^pico%.%d+$'] = 'mail',
['mutt%-.*%-%w+'] = 'mail', ['^mutt%-.*%-%w+$'] = 'mail',
['muttng%-.*%-%w+'] = 'mail', ['^muttng%-.*%-%w+$'] = 'mail',
['neomutt%-.*%-%w+'] = 'mail', ['^neomutt%-.*%-%w+$'] = 'mail',
['mutt' .. string.rep('[%w_-]', 6)] = 'mail', ['^mutt' .. string.rep('[%w_-]', 6) .. '$'] = 'mail',
['neomutt' .. string.rep('[%w_-]', 6)] = 'mail', ['^neomutt' .. string.rep('[%w_-]', 6) .. '$'] = 'mail',
['snd%.%d+'] = 'mail', ['^snd%.%d+$'] = 'mail',
['reportbug%-.*'] = starsetf('mail'), ['^reportbug%-'] = starsetf('mail'),
['.*/etc/mail/aliases'] = 'mailaliases', ['/etc/mail/aliases$'] = 'mailaliases',
['.*/etc/aliases'] = 'mailaliases', ['/etc/aliases$'] = 'mailaliases',
['.*[mM]akefile'] = 'make', ['[mM]akefile$'] = 'make',
['[mM]akefile.*'] = starsetf('make'), ['^[mM]akefile'] = starsetf('make'),
['.*/etc/man%.conf'] = 'manconf', ['/etc/man%.conf$'] = 'manconf',
['.*/log/auth'] = 'messages', ['/log/auth$'] = 'messages',
['.*/log/cron'] = 'messages', ['/log/cron$'] = 'messages',
['.*/log/daemon'] = 'messages', ['/log/daemon$'] = 'messages',
['.*/log/debug'] = 'messages', ['/log/debug$'] = 'messages',
['.*/log/kern'] = 'messages', ['/log/kern$'] = 'messages',
['.*/log/lpr'] = 'messages', ['/log/lpr$'] = 'messages',
['.*/log/mail'] = 'messages', ['/log/mail$'] = 'messages',
['.*/log/messages'] = 'messages', ['/log/messages$'] = 'messages',
['.*/log/news/news'] = 'messages', ['/log/news/news$'] = 'messages',
['.*/log/syslog'] = 'messages', ['/log/syslog$'] = 'messages',
['.*/log/user'] = 'messages', ['/log/user$'] = 'messages',
['.*/log/auth%.log'] = 'messages', ['/log/auth%.log$'] = 'messages',
['.*/log/cron%.log'] = 'messages', ['/log/cron%.log$'] = 'messages',
['.*/log/daemon%.log'] = 'messages', ['/log/daemon%.log$'] = 'messages',
['.*/log/debug%.log'] = 'messages', ['/log/debug%.log$'] = 'messages',
['.*/log/kern%.log'] = 'messages', ['/log/kern%.log$'] = 'messages',
['.*/log/lpr%.log'] = 'messages', ['/log/lpr%.log$'] = 'messages',
['.*/log/mail%.log'] = 'messages', ['/log/mail%.log$'] = 'messages',
['.*/log/messages%.log'] = 'messages', ['/log/messages%.log$'] = 'messages',
['.*/log/news/news%.log'] = 'messages', ['/log/news/news%.log$'] = 'messages',
['.*/log/syslog%.log'] = 'messages', ['/log/syslog%.log$'] = 'messages',
['.*/log/user%.log'] = 'messages', ['/log/user%.log$'] = 'messages',
['.*/log/auth%.err'] = 'messages', ['/log/auth%.err$'] = 'messages',
['.*/log/cron%.err'] = 'messages', ['/log/cron%.err$'] = 'messages',
['.*/log/daemon%.err'] = 'messages', ['/log/daemon%.err$'] = 'messages',
['.*/log/debug%.err'] = 'messages', ['/log/debug%.err$'] = 'messages',
['.*/log/kern%.err'] = 'messages', ['/log/kern%.err$'] = 'messages',
['.*/log/lpr%.err'] = 'messages', ['/log/lpr%.err$'] = 'messages',
['.*/log/mail%.err'] = 'messages', ['/log/mail%.err$'] = 'messages',
['.*/log/messages%.err'] = 'messages', ['/log/messages%.err$'] = 'messages',
['.*/log/news/news%.err'] = 'messages', ['/log/news/news%.err$'] = 'messages',
['.*/log/syslog%.err'] = 'messages', ['/log/syslog%.err$'] = 'messages',
['.*/log/user%.err'] = 'messages', ['/log/user%.err$'] = 'messages',
['.*/log/auth%.info'] = 'messages', ['/log/auth%.info$'] = 'messages',
['.*/log/cron%.info'] = 'messages', ['/log/cron%.info$'] = 'messages',
['.*/log/daemon%.info'] = 'messages', ['/log/daemon%.info$'] = 'messages',
['.*/log/debug%.info'] = 'messages', ['/log/debug%.info$'] = 'messages',
['.*/log/kern%.info'] = 'messages', ['/log/kern%.info$'] = 'messages',
['.*/log/lpr%.info'] = 'messages', ['/log/lpr%.info$'] = 'messages',
['.*/log/mail%.info'] = 'messages', ['/log/mail%.info$'] = 'messages',
['.*/log/messages%.info'] = 'messages', ['/log/messages%.info$'] = 'messages',
['.*/log/news/news%.info'] = 'messages', ['/log/news/news%.info$'] = 'messages',
['.*/log/syslog%.info'] = 'messages', ['/log/syslog%.info$'] = 'messages',
['.*/log/user%.info'] = 'messages', ['/log/user%.info$'] = 'messages',
['.*/log/auth%.warn'] = 'messages', ['/log/auth%.warn$'] = 'messages',
['.*/log/cron%.warn'] = 'messages', ['/log/cron%.warn$'] = 'messages',
['.*/log/daemon%.warn'] = 'messages', ['/log/daemon%.warn$'] = 'messages',
['.*/log/debug%.warn'] = 'messages', ['/log/debug%.warn$'] = 'messages',
['.*/log/kern%.warn'] = 'messages', ['/log/kern%.warn$'] = 'messages',
['.*/log/lpr%.warn'] = 'messages', ['/log/lpr%.warn$'] = 'messages',
['.*/log/mail%.warn'] = 'messages', ['/log/mail%.warn$'] = 'messages',
['.*/log/messages%.warn'] = 'messages', ['/log/messages%.warn$'] = 'messages',
['.*/log/news/news%.warn'] = 'messages', ['/log/news/news%.warn$'] = 'messages',
['.*/log/syslog%.warn'] = 'messages', ['/log/syslog%.warn$'] = 'messages',
['.*/log/user%.warn'] = 'messages', ['/log/user%.warn$'] = 'messages',
['.*/log/auth%.crit'] = 'messages', ['/log/auth%.crit$'] = 'messages',
['.*/log/cron%.crit'] = 'messages', ['/log/cron%.crit$'] = 'messages',
['.*/log/daemon%.crit'] = 'messages', ['/log/daemon%.crit$'] = 'messages',
['.*/log/debug%.crit'] = 'messages', ['/log/debug%.crit$'] = 'messages',
['.*/log/kern%.crit'] = 'messages', ['/log/kern%.crit$'] = 'messages',
['.*/log/lpr%.crit'] = 'messages', ['/log/lpr%.crit$'] = 'messages',
['.*/log/mail%.crit'] = 'messages', ['/log/mail%.crit$'] = 'messages',
['.*/log/messages%.crit'] = 'messages', ['/log/messages%.crit$'] = 'messages',
['.*/log/news/news%.crit'] = 'messages', ['/log/news/news%.crit$'] = 'messages',
['.*/log/syslog%.crit'] = 'messages', ['/log/syslog%.crit$'] = 'messages',
['.*/log/user%.crit'] = 'messages', ['/log/user%.crit$'] = 'messages',
['.*/log/auth%.notice'] = 'messages', ['/log/auth%.notice$'] = 'messages',
['.*/log/cron%.notice'] = 'messages', ['/log/cron%.notice$'] = 'messages',
['.*/log/daemon%.notice'] = 'messages', ['/log/daemon%.notice$'] = 'messages',
['.*/log/debug%.notice'] = 'messages', ['/log/debug%.notice$'] = 'messages',
['.*/log/kern%.notice'] = 'messages', ['/log/kern%.notice$'] = 'messages',
['.*/log/lpr%.notice'] = 'messages', ['/log/lpr%.notice$'] = 'messages',
['.*/log/mail%.notice'] = 'messages', ['/log/mail%.notice$'] = 'messages',
['.*/log/messages%.notice'] = 'messages', ['/log/messages%.notice$'] = 'messages',
['.*/log/news/news%.notice'] = 'messages', ['/log/news/news%.notice$'] = 'messages',
['.*/log/syslog%.notice'] = 'messages', ['/log/syslog%.notice$'] = 'messages',
['.*/log/user%.notice'] = 'messages', ['/log/user%.notice$'] = 'messages',
['.*%.[Mm][Oo][Dd]'] = detect.mod, ['%.[Mm][Oo][Dd]$'] = detect.mod,
['.*/etc/modules%.conf'] = 'modconf', ['/etc/modules%.conf$'] = 'modconf',
['.*/etc/conf%.modules'] = 'modconf', ['/etc/conf%.modules$'] = 'modconf',
['.*/etc/modules'] = 'modconf', ['/etc/modules$'] = 'modconf',
['.*/etc/modprobe%..*'] = starsetf('modconf'), ['/etc/modprobe%.'] = starsetf('modconf'),
['.*/etc/modutils/.*'] = starsetf(function(path, bufnr) ['/etc/modutils/'] = starsetf(function(path, bufnr)
if fn.executable(fn.expand(path)) ~= 1 then if fn.executable(fn.expand(path)) ~= 1 then
return 'modconf' return 'modconf'
end end
end), end),
['Muttrc'] = 'muttrc', ['^Muttrc$'] = 'muttrc',
['Muttngrc'] = 'muttrc', ['^Muttngrc$'] = 'muttrc',
['.*/etc/Muttrc%.d/.*'] = starsetf('muttrc'), ['/etc/Muttrc%.d/'] = starsetf('muttrc'),
['.*/%.mplayer/config'] = 'mplayerconf', ['/%.mplayer/config$'] = 'mplayerconf',
['Muttrc.*'] = detect_muttrc, ['^Muttrc'] = detect_muttrc,
['Muttngrc.*'] = detect_muttrc, ['^Muttngrc'] = detect_muttrc,
-- muttrc* and .muttrc* -- muttrc* and .muttrc*
['%.?muttrc.*'] = detect_muttrc, ['^%.?muttrc'] = detect_muttrc,
-- muttngrc* and .muttngrc* -- muttngrc* and .muttngrc*
['%.?muttngrc.*'] = detect_muttrc, ['^%.?muttngrc'] = detect_muttrc,
['.*/%.mutt/muttrc.*'] = detect_muttrc, ['/%.mutt/muttrc'] = detect_muttrc,
['.*/%.muttng/muttrc.*'] = detect_muttrc, ['/%.muttng/muttrc'] = detect_muttrc,
['.*/%.muttng/muttngrc.*'] = detect_muttrc, ['/%.muttng/muttngrc'] = detect_muttrc,
['rndc.*%.conf'] = 'named', ['^rndc.*%.conf$'] = 'named',
['rndc.*%.key'] = 'named', ['^rndc.*%.key$'] = 'named',
['named.*%.conf'] = 'named', ['^named.*%.conf$'] = 'named',
['.*/etc/nanorc'] = 'nanorc', ['/etc/nanorc$'] = 'nanorc',
['.*%.NS[ACGLMNPS]'] = 'natural', ['%.NS[ACGLMNPS]$'] = 'natural',
['Neomuttrc.*'] = detect_neomuttrc, ['^Neomuttrc'] = detect_neomuttrc,
-- neomuttrc* and .neomuttrc* -- neomuttrc* and .neomuttrc*
['%.?neomuttrc.*'] = detect_neomuttrc, ['^%.?neomuttrc'] = detect_neomuttrc,
['.*/%.neomutt/neomuttrc.*'] = detect_neomuttrc, ['/%.neomutt/neomuttrc'] = detect_neomuttrc,
['nginx.*%.conf'] = 'nginx', ['^nginx.*%.conf$'] = 'nginx',
['.*/etc/nginx/.*'] = 'nginx', ['/etc/nginx/'] = 'nginx',
['.*nginx%.conf'] = 'nginx', ['nginx%.conf$'] = 'nginx',
['.*/nginx/.*%.conf'] = 'nginx', ['/nginx/.*%.conf$'] = 'nginx',
['.*/usr/local/nginx/conf/.*'] = 'nginx', ['/usr/local/nginx/conf/'] = 'nginx',
['.*%.[1-9]'] = detect.nroff, ['%.[1-9]$'] = detect.nroff,
['.*%.ml%.cppo'] = 'ocaml', ['%.ml%.cppo$'] = 'ocaml',
['.*%.mli%.cppo'] = 'ocaml', ['%.mli%.cppo$'] = 'ocaml',
['.*/octave/history'] = 'octave', ['/octave/history$'] = 'octave',
['.*%.opam%.template'] = 'opam', ['%.opam%.template$'] = 'opam',
['.*/openvpn/.*/.*%.conf'] = 'openvpn', ['/openvpn/.*/.*%.conf$'] = 'openvpn',
['.*%.[Oo][Pp][Ll]'] = 'opl', ['%.[Oo][Pp][Ll]$'] = 'opl',
['.*/etc/pam%.conf'] = 'pamconf', ['/etc/pam%.conf$'] = 'pamconf',
['.*/etc/pam%.d/.*'] = starsetf('pamconf'), ['/etc/pam%.d/'] = starsetf('pamconf'),
['.*/etc/passwd%-'] = 'passwd', ['/etc/passwd%-$'] = 'passwd',
['.*/etc/shadow'] = 'passwd', ['/etc/shadow$'] = 'passwd',
['.*/etc/shadow%.edit'] = 'passwd', ['/etc/shadow%.edit$'] = 'passwd',
['.*/var/backups/shadow%.bak'] = 'passwd', ['/var/backups/shadow%.bak$'] = 'passwd',
['.*/var/backups/passwd%.bak'] = 'passwd', ['/var/backups/passwd%.bak$'] = 'passwd',
['.*/etc/passwd'] = 'passwd', ['/etc/passwd$'] = 'passwd',
['.*/etc/passwd%.edit'] = 'passwd', ['/etc/passwd%.edit$'] = 'passwd',
['.*/etc/shadow%-'] = 'passwd', ['/etc/shadow%-$'] = 'passwd',
['%.?gitolite%.rc'] = 'perl', ['^%.?gitolite%.rc$'] = 'perl',
['example%.gitolite%.rc'] = 'perl', ['^example%.gitolite%.rc$'] = 'perl',
['.*%.php%d'] = 'php', ['%.php%d$'] = 'php',
['.*/%.pinforc'] = 'pinfo', ['/%.pinforc$'] = 'pinfo',
['.*/etc/pinforc'] = 'pinfo', ['/etc/pinforc$'] = 'pinfo',
['.*%.[Pp][Rr][Gg]'] = detect.prg, ['%.[Pp][Rr][Gg]$'] = detect.prg,
['.*/etc/protocols'] = 'protocols', ['/etc/protocols$'] = 'protocols',
['.*printcap.*'] = starsetf(function(path, bufnr) ['printcap'] = starsetf(function(path, bufnr)
return require('vim.filetype.detect').printcap('print') return require('vim.filetype.detect').printcap('print')
end), end),
['.*baseq[2-3]/.*%.cfg'] = 'quake', ['baseq[2-3]/.*%.cfg$'] = 'quake',
['.*quake[1-3]/.*%.cfg'] = 'quake', ['quake[1-3]/.*%.cfg$'] = 'quake',
['.*id1/.*%.cfg'] = 'quake', ['id1/.*%.cfg$'] = 'quake',
['.*/queries/.*%.scm'] = 'query', -- treesitter queries (Neovim only) ['/queries/.*%.scm$'] = 'query', -- treesitter queries (Neovim only)
['.*,v'] = 'rcs', [',v$'] = 'rcs',
['%.reminders.*'] = starsetf('remind'), ['^%.reminders'] = starsetf('remind'),
['.*%-requirements%.txt'] = 'requirements', ['%-requirements%.txt$'] = 'requirements',
['requirements/.*%.txt'] = 'requirements', ['^requirements/.*%.txt$'] = 'requirements',
['requires/.*%.txt'] = 'requirements', ['^requires/.*%.txt$'] = 'requirements',
['[rR]akefile.*'] = starsetf('ruby'), ['^[rR]akefile'] = starsetf('ruby'),
['[rR]antfile'] = 'ruby', ['^[rR]antfile$'] = 'ruby',
['[rR]akefile'] = 'ruby', ['^[rR]akefile$'] = 'ruby',
['.*/etc/sensors%.d/[^.].*'] = starsetf('sensors'), ['/etc/sensors%.d/[^.]'] = starsetf('sensors'),
['.*/etc/sensors%.conf'] = 'sensors', ['/etc/sensors%.conf$'] = 'sensors',
['.*/etc/sensors3%.conf'] = 'sensors', ['/etc/sensors3%.conf$'] = 'sensors',
['.*/etc/services'] = 'services', ['/etc/services$'] = 'services',
['.*/etc/serial%.conf'] = 'setserial', ['/etc/serial%.conf$'] = 'setserial',
['.*/etc/udev/cdsymlinks%.conf'] = 'sh', ['/etc/udev/cdsymlinks%.conf$'] = 'sh',
['.*/neofetch/config%.conf'] = 'sh', ['/neofetch/config%.conf$'] = 'sh',
['%.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,
['%.kshrc.*'] = detect.ksh, ['^%.kshrc'] = detect.ksh,
['%.profile.*'] = detect.sh, ['^%.profile'] = detect.sh,
['.*/etc/profile'] = detect.sh, ['/etc/profile$'] = detect.sh,
['bash%-fc[%-%.].*'] = detect.bash, ['^bash%-fc[%-%.]'] = detect.bash,
['%.tcshrc.*'] = detect.tcsh, ['^%.tcshrc'] = detect.tcsh,
['.*/etc/sudoers%.d/.*'] = starsetf('sudoers'), ['/etc/sudoers%.d/'] = starsetf('sudoers'),
['.*%._sst%.meta'] = 'sisu', ['%._sst%.meta$'] = 'sisu',
['.*%.%-sst%.meta'] = 'sisu', ['%.%-sst%.meta$'] = 'sisu',
['.*%.sst%.meta'] = 'sisu', ['%.sst%.meta$'] = 'sisu',
['.*/etc/slp%.conf'] = 'slpconf', ['/etc/slp%.conf$'] = 'slpconf',
['.*/etc/slp%.reg'] = 'slpreg', ['/etc/slp%.reg$'] = 'slpreg',
['.*/etc/slp%.spi'] = 'slpspi', ['/etc/slp%.spi$'] = 'slpspi',
['.*/etc/ssh/ssh_config%.d/.*%.conf'] = 'sshconfig', ['/etc/ssh/ssh_config%.d/.*%.conf$'] = 'sshconfig',
['.*/%.ssh/config'] = 'sshconfig', ['/%.ssh/config$'] = 'sshconfig',
['.*/%.ssh/.*%.conf'] = 'sshconfig', ['/%.ssh/.*%.conf$'] = 'sshconfig',
['.*/etc/ssh/sshd_config%.d/.*%.conf'] = 'sshdconfig', ['/etc/ssh/sshd_config%.d/.*%.conf$'] = 'sshdconfig',
['.*%.[Ss][Rr][Cc]'] = detect.src, ['%.[Ss][Rr][Cc]$'] = detect.src,
['.*/etc/sudoers'] = 'sudoers', ['/etc/sudoers$'] = 'sudoers',
['svn%-commit.*%.tmp'] = 'svn', ['^svn%-commit.*%.tmp$'] = 'svn',
['.*/sway/config'] = 'swayconfig', ['/sway/config$'] = 'swayconfig',
['.*/%.sway/config'] = 'swayconfig', ['/%.sway/config$'] = 'swayconfig',
['.*%.swift%.gyb'] = 'swiftgyb', ['%.swift%.gyb$'] = 'swiftgyb',
['.*%.[Ss][Yy][Ss]'] = detect.sys, ['%.[Ss][Yy][Ss]$'] = detect.sys,
['.*/etc/sysctl%.conf'] = 'sysctl', ['/etc/sysctl%.conf$'] = 'sysctl',
['.*/etc/sysctl%.d/.*%.conf'] = 'sysctl', ['/etc/sysctl%.d/.*%.conf$'] = 'sysctl',
['.*/systemd/.*%.automount'] = 'systemd', ['/systemd/.*%.automount$'] = 'systemd',
['.*/systemd/.*%.dnssd'] = 'systemd', ['/systemd/.*%.dnssd$'] = 'systemd',
['.*/systemd/.*%.link'] = 'systemd', ['/systemd/.*%.link$'] = 'systemd',
['.*/systemd/.*%.mount'] = 'systemd', ['/systemd/.*%.mount$'] = 'systemd',
['.*/systemd/.*%.netdev'] = 'systemd', ['/systemd/.*%.netdev$'] = 'systemd',
['.*/systemd/.*%.network'] = 'systemd', ['/systemd/.*%.network$'] = 'systemd',
['.*/systemd/.*%.nspawn'] = 'systemd', ['/systemd/.*%.nspawn$'] = 'systemd',
['.*/systemd/.*%.path'] = 'systemd', ['/systemd/.*%.path$'] = 'systemd',
['.*/systemd/.*%.service'] = 'systemd', ['/systemd/.*%.service$'] = 'systemd',
['.*/systemd/.*%.slice'] = 'systemd', ['/systemd/.*%.slice$'] = 'systemd',
['.*/systemd/.*%.socket'] = 'systemd', ['/systemd/.*%.socket$'] = 'systemd',
['.*/systemd/.*%.swap'] = 'systemd', ['/systemd/.*%.swap$'] = 'systemd',
['.*/systemd/.*%.target'] = 'systemd', ['/systemd/.*%.target$'] = 'systemd',
['.*/systemd/.*%.timer'] = 'systemd', ['/systemd/.*%.timer$'] = 'systemd',
['.*/etc/systemd/.*%.conf%.d/.*%.conf'] = 'systemd', ['/etc/systemd/.*%.conf%.d/.*%.conf$'] = 'systemd',
['.*/%.config/systemd/user/.*%.d/.*%.conf'] = 'systemd', ['/%.config/systemd/user/.*%.d/.*%.conf$'] = 'systemd',
['.*/etc/systemd/system/.*%.d/.*%.conf'] = 'systemd', ['/etc/systemd/system/.*%.d/.*%.conf$'] = 'systemd',
['.*/etc/systemd/system/.*%.d/%.#.*'] = 'systemd', ['/etc/systemd/system/.*%.d/%.#'] = 'systemd',
['.*/etc/systemd/system/%.#.*'] = 'systemd', ['/etc/systemd/system/%.#'] = 'systemd',
['.*/%.config/systemd/user/.*%.d/%.#.*'] = 'systemd', ['/%.config/systemd/user/.*%.d/%.#'] = 'systemd',
['.*/%.config/systemd/user/%.#.*'] = 'systemd', ['/%.config/systemd/user/%.#'] = 'systemd',
['.*termcap.*'] = starsetf(function(path, bufnr) ['termcap'] = starsetf(function(path, bufnr)
return require('vim.filetype.detect').printcap('term') return require('vim.filetype.detect').printcap('term')
end), end),
['.*/tex/latex/.*%.cfg'] = 'tex', ['/tex/latex/.*%.cfg$'] = 'tex',
['.*%.t%.html'] = 'tilde', ['%.t%.html$'] = 'tilde',
['%.?tmux.*%.conf'] = 'tmux', ['^%.?tmux.*%.conf$'] = 'tmux',
['%.?tmux.*%.conf.*'] = { 'tmux', { priority = -1 } }, ['^%.?tmux.*%.conf'] = { 'tmux', { priority = -1 } },
['.*/%.cargo/config'] = 'toml', ['/%.cargo/config$'] = 'toml',
['.*/%.cargo/credentials'] = 'toml', ['/%.cargo/credentials$'] = 'toml',
['.*/etc/udev/udev%.conf'] = 'udevconf', ['/etc/udev/udev%.conf$'] = 'udevconf',
['.*/etc/udev/permissions%.d/.*%.permissions'] = 'udevperm', ['/etc/udev/permissions%.d/.*%.permissions$'] = 'udevperm',
['.*/etc/updatedb%.conf'] = 'updatedb', ['/etc/updatedb%.conf$'] = 'updatedb',
['.*/%.init/.*%.override'] = 'upstart', ['/%.init/.*%.override$'] = 'upstart',
['.*/usr/share/upstart/.*%.conf'] = 'upstart', ['/usr/share/upstart/.*%.conf$'] = 'upstart',
['.*/%.config/upstart/.*%.override'] = 'upstart', ['/%.config/upstart/.*%.override$'] = 'upstart',
['.*/etc/init/.*%.conf'] = 'upstart', ['/etc/init/.*%.conf$'] = 'upstart',
['.*/etc/init/.*%.override'] = 'upstart', ['/etc/init/.*%.override$'] = 'upstart',
['.*/%.config/upstart/.*%.conf'] = 'upstart', ['/%.config/upstart/.*%.conf$'] = 'upstart',
['.*/%.init/.*%.conf'] = 'upstart', ['/%.init/.*%.conf$'] = 'upstart',
['.*/usr/share/upstart/.*%.override'] = 'upstart', ['/usr/share/upstart/.*%.override$'] = 'upstart',
['.*%.[Ll][Oo][Gg]'] = detect.log, ['%.[Ll][Oo][Gg]$'] = detect.log,
['.*/etc/config/.*'] = starsetf(detect.uci), ['/etc/config/'] = starsetf(detect.uci),
['.*%.vhdl_[0-9].*'] = starsetf('vhdl'), ['%.vhdl_[0-9]'] = starsetf('vhdl'),
['.*/Xresources/.*'] = starsetf('xdefaults'), ['/Xresources/'] = starsetf('xdefaults'),
['.*/app%-defaults/.*'] = starsetf('xdefaults'), ['/app%-defaults/'] = starsetf('xdefaults'),
['.*/etc/xinetd%.conf'] = 'xinetd', ['/etc/xinetd%.conf$'] = 'xinetd',
['.*/usr/share/X11/xkb/compat/.*'] = starsetf('xkb'), ['/usr/share/X11/xkb/compat/'] = starsetf('xkb'),
['.*/usr/share/X11/xkb/geometry/.*'] = starsetf('xkb'), ['/usr/share/X11/xkb/geometry/'] = starsetf('xkb'),
['.*/usr/share/X11/xkb/keycodes/.*'] = starsetf('xkb'), ['/usr/share/X11/xkb/keycodes/'] = starsetf('xkb'),
['.*/usr/share/X11/xkb/symbols/.*'] = starsetf('xkb'), ['/usr/share/X11/xkb/symbols/'] = starsetf('xkb'),
['.*/usr/share/X11/xkb/types/.*'] = starsetf('xkb'), ['/usr/share/X11/xkb/types/'] = starsetf('xkb'),
['.*/etc/blkid%.tab'] = 'xml', ['/etc/blkid%.tab$'] = 'xml',
['.*/etc/blkid%.tab%.old'] = 'xml', ['/etc/blkid%.tab%.old$'] = 'xml',
['.*%.vbproj%.user'] = 'xml', ['%.vbproj%.user$'] = 'xml',
['.*%.fsproj%.user'] = 'xml', ['%.fsproj%.user$'] = 'xml',
['.*%.csproj%.user'] = 'xml', ['%.csproj%.user$'] = 'xml',
['.*/etc/xdg/menus/.*%.menu'] = 'xml', ['/etc/xdg/menus/.*%.menu$'] = 'xml',
['.*Xmodmap'] = 'xmodmap', ['Xmodmap$'] = 'xmodmap',
['.*/etc/zprofile'] = 'zsh', ['/etc/zprofile$'] = 'zsh',
['.*vimrc.*'] = starsetf('vim'), ['vimrc'] = starsetf('vim'),
['Xresources.*'] = starsetf('xdefaults'), ['^Xresources'] = starsetf('xdefaults'),
['.*/etc/xinetd%.d/.*'] = starsetf('xinetd'), ['/etc/xinetd%.d/'] = starsetf('xinetd'),
['.*xmodmap.*'] = starsetf('xmodmap'), ['xmodmap'] = starsetf('xmodmap'),
['.*/xorg%.conf%.d/.*%.conf'] = detect.xfree86_v4, ['/xorg%.conf%.d/.*%.conf$'] = detect.xfree86_v4,
-- Increase priority to run before the pattern below -- Increase priority to run before the pattern below
['XF86Config%-4.*'] = starsetf(detect.xfree86_v4, { priority = -math.huge + 1 }), ['^XF86Config%-4'] = starsetf(detect.xfree86_v4, { priority = -math.huge + 1 }),
['XF86Config.*'] = starsetf(detect.xfree86_v3), ['^XF86Config'] = starsetf(detect.xfree86_v3),
['.*/%.bundle/config'] = 'yaml', ['/%.bundle/config$'] = 'yaml',
['%.zcompdump.*'] = starsetf('zsh'), ['^%.zcompdump'] = starsetf('zsh'),
-- .zlog* and zlog* -- .zlog* and zlog*
['%.?zlog.*'] = starsetf('zsh'), ['^%.?zlog'] = starsetf('zsh'),
-- .zsh* and zsh* -- .zsh* and zsh*
['%.?zsh.*'] = starsetf('zsh'), ['^%.?zsh'] = starsetf('zsh'),
-- Ignored extension -- Ignored extension
['.*~'] = function(path, bufnr) ['~$'] = function(path, bufnr)
local short = path:gsub('~+$', '', 1) local short = path:gsub('~+$', '', 1)
if path ~= short and short ~= '' then if path ~= short and short ~= '' then
return M.match({ buf = bufnr, filename = fn.fnameescape(short) }) return M.match({ buf = bufnr, filename = fn.fnameescape(short) })
@@ -2219,7 +2222,7 @@ local pattern = {
-- luacheck: pop -- luacheck: pop
--- Lookup table/cache for patterns --- Lookup table/cache for patterns
--- @alias vim.filetype.pattern_cache { fullpat: string, has_env: boolean, has_slash: boolean } --- @alias vim.filetype.pattern_cache { has_env: boolean, has_slash: boolean }
--- @type table<string,vim.filetype.pattern_cache> --- @type table<string,vim.filetype.pattern_cache>
local pattern_lookup = {} local pattern_lookup = {}
@@ -2243,11 +2246,8 @@ local function sort_by_priority(t)
) )
-- Parse pattern for common data and cache it once -- Parse pattern for common data and cache it once
pattern_lookup[pat] = pattern_lookup[pat] or { pattern_lookup[pat] = pattern_lookup[pat]
fullpat = '^' .. pat .. '$', or { has_env = pat:find('%$%b{}') ~= nil, has_slash = pat:find('/') ~= nil }
has_env = pat:find('%$%b{}') ~= nil,
has_slash = pat:find('/') ~= nil,
}
local opts = (type(maptbl) == 'table' and type(maptbl[2]) == 'table') and maptbl[2] or {} local opts = (type(maptbl) == 'table' and type(maptbl[2]) == 'table') and maptbl[2] or {}
opts.priority = opts.priority or 0 opts.priority = opts.priority or 0
@@ -2380,7 +2380,8 @@ function M.add(filetypes)
end end
for k, v in pairs(filetypes.pattern or {}) do for k, v in pairs(filetypes.pattern or {}) do
pattern[normalize_path(k, true)] = v -- User patterns are assumed to be implicitly anchored (as in Vim)
pattern['^' .. normalize_path(k, true) .. '$'] = v
end end
if filetypes.pattern then if filetypes.pattern then
@@ -2450,15 +2451,15 @@ end
--- @return string|boolean? --- @return string|boolean?
local function match_pattern(name, path, tail, pat) local function match_pattern(name, path, tail, pat)
local pat_cache = pattern_lookup[pat] local pat_cache = pattern_lookup[pat]
local fullpat, has_slash = pat_cache.fullpat, pat_cache.has_slash local has_slash = pat_cache.has_slash
if pat_cache.has_env then if pat_cache.has_env then
local some_env_missing, expanded = expand_envvar_pattern(fullpat) local some_env_missing, expanded = expand_envvar_pattern(pat)
-- If any environment variable is present in the pattern but not set, there is no match -- If any environment variable is present in the pattern but not set, there is no match
if some_env_missing then if some_env_missing then
return false return false
end end
fullpat, has_slash = expanded, expanded:find('/') ~= nil pat, has_slash = expanded, expanded:find('/') ~= nil
end end
-- If the pattern contains a / match against the full path, otherwise just the tail -- If the pattern contains a / match against the full path, otherwise just the tail
@@ -2466,10 +2467,10 @@ local function match_pattern(name, path, tail, pat)
-- Similar to |autocmd-pattern|, if the pattern contains a '/' then check for a match against -- Similar to |autocmd-pattern|, if the pattern contains a '/' then check for a match against
-- both the short file name (as typed) and the full file name (after expanding to full path -- both the short file name (as typed) and the full file name (after expanding to full path
-- and resolving symlinks) -- and resolving symlinks)
return (name:match(fullpat) or path:match(fullpat)) return (name:match(pat) or path:match(pat))
end end
return (tail:match(fullpat)) return (tail:match(pat))
end end
--- @param name string --- @param name string