1
0
forked from aniani/vim

patch 9.0.1601: filetype detection fails for *.conf file without comments

Problem:    Filetype detection fails for *.conf file without comments.
            (Dmitrii Tcyganok)
Solution:   Use "conf" filetype as a fallback for an empty .conf file.
            (closes #12487, closes #12483)
This commit is contained in:
zeertzjq 2023-06-03 17:56:30 +01:00 committed by Bram Moolenaar
parent f0e68c0e2a
commit 664fd12aa2
3 changed files with 7 additions and 3 deletions

View File

@ -2811,8 +2811,10 @@ augroup END
" Generic configuration file. Use FALLBACK, it's just guessing! " Generic configuration file. Use FALLBACK, it's just guessing!
au filetypedetect BufNewFile,BufRead,StdinReadPost * au filetypedetect BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
\ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' \ && (expand("<amatch>") =~# '\.conf$'
\ || getline(4) =~ '^#' || getline(5) =~ '^#') | \ || getline(1) =~ '^#' || getline(2) =~ '^#'
\ || getline(3) =~ '^#' || getline(4) =~ '^#'
\ || getline(5) =~ '^#') |
\ setf FALLBACK conf | \ setf FALLBACK conf |
\ endif \ endif

View File

@ -122,7 +122,7 @@ def s:GetFilenameChecks(): dict<list<string>>
cobol: ['file.cbl', 'file.cob', 'file.lib'], cobol: ['file.cbl', 'file.cob', 'file.lib'],
coco: ['file.atg'], coco: ['file.atg'],
conaryrecipe: ['file.recipe'], conaryrecipe: ['file.recipe'],
conf: ['auto.master'], conf: ['auto.master', 'file.conf'],
config: ['configure.in', 'configure.ac', '/etc/hostname.file', 'any/etc/hostname.file'], config: ['configure.in', 'configure.ac', '/etc/hostname.file', 'any/etc/hostname.file'],
confini: ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'], confini: ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'], context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],

View File

@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1601,
/**/ /**/
1600, 1600,
/**/ /**/