]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1601: filetype detection fails for *.conf file without comments v9.0.1601
authorzeertzjq <zeertzjq@outlook.com>
Sat, 3 Jun 2023 16:56:30 +0000 (17:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 3 Jun 2023 16:56:30 +0000 (17:56 +0100)
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)

runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 4be0f18a7d310ca60c68ddc0712062268ed6c58e..e9116688af5c2d25b7b14d73c16add4a0e3a820f 100644 (file)
@@ -2811,8 +2811,10 @@ augroup END
 " Generic configuration file. Use FALLBACK, it's just guessing!
 au filetypedetect BufNewFile,BufRead,StdinReadPost *
        \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
-       \    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
-       \       || getline(4) =~ '^#' || getline(5) =~ '^#') |
+       \    && (expand("<amatch>") =~# '\.conf$'
+       \       || getline(1) =~ '^#' || getline(2) =~ '^#'
+       \       || getline(3) =~ '^#' || getline(4) =~ '^#'
+       \       || getline(5) =~ '^#') |
        \   setf FALLBACK conf |
        \ endif
 
index 0684383ee4e3d2ec59f75c7bcd16410321dc9a62..6e03a70c8ec8e524b0adeabc9844c514e21399db 100644 (file)
@@ -122,7 +122,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     cobol: ['file.cbl', 'file.cob', 'file.lib'],
     coco: ['file.atg'],
     conaryrecipe: ['file.recipe'],
-    conf: ['auto.master'],
+    conf: ['auto.master', 'file.conf'],
     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'],
     context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],
index b854893fc363bc41ca96dfdfba6bdb6361cf3221..e373686ab52923561840a5337757704afd0b35ab 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1601,
 /**/
     1600,
 /**/