diff options
| author | Fernando Schauenburg <dev@schauenburg.me> | 2023-01-30 08:01:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-30 08:01:35 +0100 |
| commit | d5f6c0911d6066397f1757c6b55a8bd6851bd6dc (patch) | |
| tree | c4af1cfed9a5eaf7decdabc9633375f39393d814 /lua | |
| parent | dce1156ca103b8222e4abbfc63f9c6887abf5ec6 (diff) | |
fix: man_pages on macOS and FreeBSD (#2326) (#2352)
macOS 13.x (Ventura, Darwin 22.x) uses `apropos(1)` from FreeBSD, which
does not behave the same as the previous implementation up to macOS 12.
`apropos(1)` takes a regular expression as an argument, so passing "."
causes it to match anything and therefore return all results to be
filtered by Telescope.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/__internal.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index 1da5cee..613643b 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -767,8 +767,16 @@ internal.man_pages = function(opts) opts.sections = vim.F.if_nil(opts.sections, { "1" }) assert(vim.tbl_islist(opts.sections), "sections should be a list") opts.man_cmd = utils.get_lazy_default(opts.man_cmd, function() - local is_darwin = vim.loop.os_uname().sysname == "Darwin" - return is_darwin and { "apropos", " " } or { "apropos", "" } + local uname = vim.loop.os_uname() + local sysname = string.lower(uname.sysname) + if sysname == "darwin" then + local major_version = tonumber(vim.fn.matchlist(uname.release, [[^\(\d\+\)\..*]])[2]) or 0 + return major_version >= 22 and { "apropos", "." } or { "apropos", " " } + elseif sysname == "freebsd" then + return { "apropos", "." } + else + return { "apropos", "" } + end end) opts.entry_maker = opts.entry_maker or make_entry.gen_from_apropos(opts) opts.env = { PATH = vim.env.PATH, MANPATH = vim.env.MANPATH } |
