mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
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
babdb0554a
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
This commit is contained in:
@@ -696,7 +696,7 @@ local extension = {
|
|||||||
lex = 'lex',
|
lex = 'lex',
|
||||||
lxx = 'lex',
|
lxx = 'lex',
|
||||||
['l++'] = 'lex',
|
['l++'] = 'lex',
|
||||||
l = 'lex',
|
l = detect_seq('lex', detect.nroff),
|
||||||
lhs = 'lhaskell',
|
lhs = 'lhaskell',
|
||||||
lidr = 'lidris2',
|
lidr = 'lidris2',
|
||||||
ly = 'lilypond',
|
ly = 'lilypond',
|
||||||
@@ -835,6 +835,7 @@ local extension = {
|
|||||||
nix = 'nix',
|
nix = 'nix',
|
||||||
norg = 'norg',
|
norg = 'norg',
|
||||||
nqc = 'nqc',
|
nqc = 'nqc',
|
||||||
|
['0'] = detect.nroff,
|
||||||
['1'] = detect.nroff,
|
['1'] = detect.nroff,
|
||||||
['2'] = detect.nroff,
|
['2'] = detect.nroff,
|
||||||
['3'] = detect.nroff,
|
['3'] = detect.nroff,
|
||||||
@@ -844,6 +845,24 @@ local extension = {
|
|||||||
['7'] = detect.nroff,
|
['7'] = detect.nroff,
|
||||||
['8'] = detect.nroff,
|
['8'] = detect.nroff,
|
||||||
['9'] = 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',
|
roff = 'nroff',
|
||||||
tmac = 'nroff',
|
tmac = 'nroff',
|
||||||
man = 'nroff',
|
man = 'nroff',
|
||||||
@@ -1390,7 +1409,7 @@ local extension = {
|
|||||||
pp = detect.pp,
|
pp = detect.pp,
|
||||||
i = detect.i,
|
i = detect.i,
|
||||||
w = detect.progress_cweb,
|
w = detect.progress_cweb,
|
||||||
p = detect.progress_pascal,
|
p = detect_seq(detect.nroff, detect.progress_pascal),
|
||||||
pro = detect_seq(detect.proto, 'idlang'),
|
pro = detect_seq(detect.proto, 'idlang'),
|
||||||
patch = detect.patch,
|
patch = detect.patch,
|
||||||
r = detect.r,
|
r = detect.r,
|
||||||
|
@@ -1175,7 +1175,7 @@ end
|
|||||||
--- @type vim.filetype.mapfn
|
--- @type vim.filetype.mapfn
|
||||||
function M.nroff(_, bufnr)
|
function M.nroff(_, bufnr)
|
||||||
for _, line in ipairs(getlines(bufnr, 1, 5)) do
|
for _, line in ipairs(getlines(bufnr, 1, 5)) do
|
||||||
if line:find('^%.') then
|
if line:find('^%.%S%S?') then
|
||||||
return 'nroff'
|
return 'nroff'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -2918,6 +2918,20 @@ func Test_map_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
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()
|
func Test_org_file()
|
||||||
filetype on
|
filetype on
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user