neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7da1639a14f99c75a7946f1161238c6e4abf4319
parent 1437144740925fc8e594d21172b54d2b00acd035
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Fri, 18 Apr 2025 08:14:18 +0800

vim-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: vim/vim#17117

https://github.com/vim/vim/commit/babdb0554a44a5e406a499bf8c315e660b2a028e

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>

Diffstat:
Mruntime/lua/vim/filetype.lua | 23+++++++++++++++++++++--
Mruntime/lua/vim/filetype/detect.lua | 2+-
Mtest/old/testdir/test_filetype.vim | 14++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua @@ -696,7 +696,7 @@ local extension = { lex = 'lex', lxx = 'lex', ['l++'] = 'lex', - l = 'lex', + l = detect_seq('lex', detect.nroff), lhs = 'lhaskell', lidr = 'lidris2', ly = 'lilypond', @@ -835,6 +835,7 @@ local extension = { nix = 'nix', norg = 'norg', nqc = 'nqc', + ['0'] = detect.nroff, ['1'] = detect.nroff, ['2'] = detect.nroff, ['3'] = detect.nroff, @@ -844,6 +845,24 @@ local extension = { ['7'] = detect.nroff, ['8'] = detect.nroff, ['9'] = detect.nroff, + ['0p'] = detect.nroff, + ['1p'] = detect.nroff, + ['3p'] = detect.nroff, + ['1x'] = detect.nroff, + ['2x'] = detect.nroff, + ['3x'] = detect.nroff, + ['4x'] = detect.nroff, + ['5x'] = detect.nroff, + ['6x'] = detect.nroff, + ['7x'] = detect.nroff, + ['8x'] = detect.nroff, + ['3am'] = detect.nroff, + ['3perl'] = detect.nroff, + ['3pm'] = detect.nroff, + ['3posix'] = detect.nroff, + ['3type'] = detect.nroff, + n = detect.nroff, + o = detect.nroff, roff = 'nroff', tmac = 'nroff', man = 'nroff', @@ -1390,7 +1409,7 @@ local extension = { pp = detect.pp, i = detect.i, w = detect.progress_cweb, - p = detect.progress_pascal, + p = detect_seq(detect.nroff, detect.progress_pascal), pro = detect_seq(detect.proto, 'idlang'), patch = detect.patch, r = detect.r, diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua @@ -1175,7 +1175,7 @@ end --- @type vim.filetype.mapfn function M.nroff(_, bufnr) for _, line in ipairs(getlines(bufnr, 1, 5)) do - if line:find('^%.') then + if line:find('^%.%S%S?') then return 'nroff' end end diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim @@ -2918,6 +2918,20 @@ func Test_map_file() filetype off endfunc +func Test_nroff_file() + filetype on + + call writefile(['.TH vim 1 "YYYY Mth DD"'], 'Xfile.1', 'D') + split Xfile.1 + call assert_equal('nroff', &filetype) + bwipe! + + call writefile(['. /etc/profile'], 'Xfile.1', 'D') + split Xfile.1 + call assert_notequal('nroff', &filetype) + bwipe! +endfunc + func Test_org_file() filetype on