From 4c51020bac00e929e04bf8f682f64a5cd6f0111a Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 29 Jan 2023 15:55:23 +0100 Subject: [PATCH] nvim: improve `Telescope man_pages` fix for macOS and FreeBSD This commit makes sure that the fix from 681dd28 is only applied when running on macOS Ventura (13.0) and upwards (i.e. Darwin >= 22.0) or FreeBSD. --- config/nvim/after/plugin/telescope.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/config/nvim/after/plugin/telescope.lua b/config/nvim/after/plugin/telescope.lua index 2cc278f..6d12a80 100644 --- a/config/nvim/after/plugin/telescope.lua +++ b/config/nvim/after/plugin/telescope.lua @@ -59,6 +59,7 @@ telescope.setup { keymaps = { prompt_title = '  Find keymaps ' }, live_grep = { prompt_title = ' 🔍 Grep ' }, vim_options = { prompt_title = '  Find options ' }, + man_pages = { prompt_title = '  Find man pages '}, }, extensions = { @@ -88,11 +89,22 @@ local custom = { end, man_pages = function() - builtin.man_pages { - prompt_title = '  Find man pages ', - sections = { 'ALL' }, - man_cmd = { "apropos", ".*" } - } + -- Fix for macOS Ventura onwards (macOS 13.x <-> Darwin 22.x). + -- See: https://github.com/nvim-telescope/telescope.nvim/issues/2326#issuecomment-1407502328 + 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 + if major_version >= 22 then + builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } } + else + builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", " " } } + end + elseif sysname == "freebsd" then + builtin.man_pages { sections = { 'ALL' }, man_cmd = { "apropos", "." } } + else + builtin.man_pages { sections = { 'ALL' } } + end end, }