patch 9.1.1304: filetype: some man files are not recognized
Problem: filetype: some man files are not recognized
(e.g. 1p (POSIX commands))
Solution: update the filetype detection pattern and detect more man
files as nroff (Eisuke Kawashima)
- sections are revised referring to
- debian-12:/etc/manpath.config
- fedora-41:/etc/man_db.conf
- detection logic is improved
- detection test is implemented
closes: #17117
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 4053e51..25c7f57 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -3,7 +3,7 @@
# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Apr 10
+# Last Change: 2025 Apr 15
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
@@ -595,11 +595,15 @@
# This function checks if one of the first five lines start with a dot. In
# that case it is probably an nroff file: 'filetype' is set and 1 is returned.
export def FTnroff(): number
- if getline(1)[0] .. getline(2)[0] .. getline(3)[0]
- .. getline(4)[0] .. getline(5)[0] =~ '\.'
- setf nroff
- return 1
- endif
+ var n = 1
+ while n < 5
+ var line = getline(n)
+ if line =~ '^\.\S\S\?'
+ setf nroff
+ return 1
+ endif
+ n += 1
+ endwhile
return 0
enddef