summaryrefslogtreecommitdiff
path: root/lua/telescope/builtin/internal.lua
diff options
context:
space:
mode:
authorJINNOUCHI Yasushi <me@delphinus.dev>2021-02-02 21:23:37 +0900
committerGitHub <noreply@github.com>2021-02-02 13:23:37 +0100
commitc422d86eb9c262606534754b5f4ee79bd01ae09a (patch)
tree9fb76bcebbddb1b234f4ba60c35f1458691b9f21 /lua/telescope/builtin/internal.lua
parent9e76b1613a25cc6f63d17eb73432523924662619 (diff)
feat: add sections opt for man_pages and fix for macos (#413)
:Telescope man_pages sections=3 will only show man pages from section 3 :Telescope man_pages sections=1,2,3 will show man pages from section 1, 2 and 3
Diffstat (limited to 'lua/telescope/builtin/internal.lua')
-rw-r--r--lua/telescope/builtin/internal.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua
index 3c34b8b..f932f48 100644
--- a/lua/telescope/builtin/internal.lua
+++ b/lua/telescope/builtin/internal.lua
@@ -429,27 +429,31 @@ internal.help_tags = function(opts)
end
internal.man_pages = function(opts)
- local pages = utils.get_os_command_output(opts.man_cmd or { 'apropos', '--sections=1', '' })
+ opts.sections = utils.get_default(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', ''}
+ end)
+ opts.entry_maker = opts.entry_maker or make_entry.gen_from_apropos(opts)
pickers.new(opts, {
prompt_title = 'Man',
- finder = finders.new_table {
- results = pages,
- entry_maker = opts.entry_maker or make_entry.gen_from_apropos(opts),
- },
+ finder = finders.new_oneshot_job(opts.man_cmd, opts),
previewer = previewers.man.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr)
actions._goto_file_selection:replace(function(_, cmd)
local selection = actions.get_selected_entry()
+ local args = selection.section .. ' ' .. selection.value
actions.close(prompt_bufnr)
if cmd == 'edit' or cmd == 'new' then
- vim.cmd('Man ' .. selection.value)
+ vim.cmd('Man ' .. args)
elseif cmd == 'vnew' then
- vim.cmd('vert bo Man ' .. selection.value)
+ vim.cmd('vert bo Man ' .. args)
elseif cmd == 'tabedit' then
- vim.cmd('tab Man ' .. selection.value)
+ vim.cmd('tab Man ' .. args)
end
end)