aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2021-12-03 13:19:17 +0100
committerGitHub <noreply@github.com>2021-12-03 13:19:17 +0100
commite225397bcb6e1cb0f1045370a8998db364dd6683 (patch)
treeafe8355be416d82dee66aa65f4410389b5e16592
parent4e352ecc42dc9c4ec0639007c13b03d5dceef619 (diff)
downloadrneovim-e225397bcb6e1cb0f1045370a8998db364dd6683.tar.gz
rneovim-e225397bcb6e1cb0f1045370a8998db364dd6683.tar.bz2
rneovim-e225397bcb6e1cb0f1045370a8998db364dd6683.zip
vim-patch:8.2.3726: README file in a config directory gets wrong filetype (#16507)
Problem: README file in a config directory gets wrong filetype. Solution: Match README before patterns that match everything in a directory. https://github.com/vim/vim/commit/c903695be54189fd7199121e9cd669e722fbc9c2
-rw-r--r--runtime/filetype.vim15
-rw-r--r--src/nvim/testdir/test_filetype.vim2
2 files changed, 11 insertions, 6 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index cc28dba1d0..f572c08e8d 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -119,7 +119,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
@@ -2158,6 +2158,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.
@@ -2172,6 +2178,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')
@@ -2365,10 +2374,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'
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 48b434b9fd..81e291d7c4 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -501,7 +501,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'],