]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3726: README file in a config directory gets wrong filetype v8.2.3726
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Dec 2021 11:44:03 +0000 (11:44 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Dec 2021 11:44:03 +0000 (11:44 +0000)
Problem:    README file in a config directory gets wrong filetype.
Solution:   Match README before patterns that match everything in a directory.

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

index f687cc77af4ffb0cac2fdd1c7980711e425429b1..0bc9926f3ad31d8f3c1a14208cf6124d237f5abc 100644 (file)
@@ -123,7 +123,7 @@ au BufNewFile,BufRead *.aml                 setf aml
 " APT config file
 au BufNewFile,BufRead apt.conf                setf aptconf
 au BufNewFile,BufRead */.aptitude/config       setf aptconf
-au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf
+" more generic pattern far down
 
 " Arch Inventory file
 au BufNewFile,BufRead .arch-inventory,=tagging-method  setf arch
@@ -2159,6 +2159,12 @@ au BufNewFile,BufRead *
 au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
 
 
+" Plain text files, needs to be far down to not override others.  This avoids
+" the "conf" type being used if there is a line starting with '#'.
+" But before patterns matching everything in a directory.
+au BufNewFile,BufRead *.text,README,LICENSE,COPYING,AUTHORS    setf text
+
+
 " Extra checks for when no filetype has been detected now.  Mostly used for
 " patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
 " script file.
@@ -2173,6 +2179,9 @@ au BufNewFile,BufRead proftpd.conf*                                       call s:StarSetf('apachestyle')
 au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf*    call s:StarSetf('apache')
 au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.*/*,*/etc/httpd/mods-*/*,*/etc/httpd/sites-*/*,*/etc/httpd/conf.d/*.conf*           call s:StarSetf('apache')
 
+" APT config file
+au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} call s:StarSetf('aptconf')
+
 " Asterisk config file
 au BufNewFile,BufRead *asterisk/*.conf*                call s:StarSetf('asterisk')
 au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
@@ -2366,10 +2375,6 @@ au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
 au BufNewFile,BufRead zsh*,zlog*               call s:StarSetf('zsh')
 
 
-" Plain text files, needs to be far down to not override others.  This avoids
-" the "conf" type being used if there is a line starting with '#'.
-au BufNewFile,BufRead *.text,README            setf text
-
 " Help files match *.txt but should have a last line that is a modeline.
 au BufNewFile,BufRead *.txt
        \  if getline('$') !~ 'vim:.*ft=help'
index f1966f43e616f4c35f690fb2a5cc18681c7a012c..7d739adcde0c277b38dc5d944b84b8a0617adf8c 100644 (file)
@@ -502,7 +502,7 @@ let s:filename_checks = {
     \ 'tex': ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl'],
     \ 'texinfo': ['file.texinfo', 'file.texi', 'file.txi'],
     \ 'texmf': ['texmf.cnf'],
-    \ 'text': ['file.text', 'README', '/usr/share/doc/bash-completion/AUTHORS'],
+    \ 'text': ['file.text', 'README', 'LICENSE', 'COPYING', 'AUTHORS', '/usr/share/doc/bash-completion/AUTHORS', '/etc/apt/apt.conf.d/README'],
     \ 'tf': ['file.tf', '.tfrc', 'tfrc'],
     \ 'tidy': ['.tidyrc', 'tidyrc', 'tidy.conf'],
     \ 'tilde': ['file.t.html'],
index c64e2c289c00259ca300163a2a73dcebcd10b1d6..942393992e23f116a36782d2172b97dd51c55583 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3726,
 /**/
     3725,
 /**/