Mercurial > vim
changeset 32539:cb37dba68329 v9.0.1601
patch 9.0.1601: filetype detection fails for *.conf file without comments
Commit: https://github.com/vim/vim/commit/664fd12aa27a3c6bd19cfa474c4630d6c03fcc61
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sat Jun 3 17:56:30 2023 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Jun 2023 19:00:04 +0200 |
parents | e61860e4ef75 |
children | c8697d448f8c |
files | runtime/filetype.vim src/testdir/test_filetype.vim src/version.c |
diffstat | 3 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -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
--- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -122,7 +122,7 @@ def s:GetFilenameChecks(): dict<list<str 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'],