diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 787a4e63d1..1dd5a3c585 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -510,6 +510,11 @@ local function get_paths(name, sect) or vim.env.MANPATH if not mandirs_raw then + -- Fall back to direct lookup ("man -w [sect] name"). NetBSD man lacks "-w". #25919 + local ok, path = pcall(M._find_path, name, sect) + if ok and path then + return { path } + end return {}, "Could not determine man directories from: 'man -w', 'manpath' or $MANPATH" end diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 330b10e4dc..40b0dac81f 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -304,6 +304,31 @@ describe(':Man', function() ) end) + it('uses direct manpage lookup if man directories cannot be determined #25919', function() + eq( + { + { + name = 'open', + filename = 'man://open(2)', + cmd = '1', + }, + }, + exec_lua(function() + local man = require('man') + vim.env.MANPATH = nil + vim.npcall = function() + return nil + end + man._find_path = function(name, sect) + if name == 'open' and sect == '2' then + return '/usr/share/man/man2/open.2' + end + end + return man.goto_tag('open(2)') + end) + ) + end) + it('tries variants with spaces, underscores #22503', function() eq({ { vim.NIL, 'NAME WITH SPACES' },