diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index a17d6dd03d..8bc7c1f05d 100644 --- 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 index c2674febc6..0497181cf7 100644 --- 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 index 9affc308ee..035beed869 100644 --- 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