summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-08-05 04:19:39 +0800
committerGitHub <noreply@github.com>2021-08-04 22:19:39 +0200
commit654903fc040148ee50f3ad510812b47de7a2f87a (patch)
treed7e7f140416db84b99108968d90090b3c974e970
parentaa7c13ea365489ec4392b753df5369f805cb9499 (diff)
fix: preview the correct man page section (#1076)
-rw-r--r--doc/telescope.txt4
-rw-r--r--lua/telescope/builtin/init.lua1
-rw-r--r--lua/telescope/previewers/buffer_previewer.lua4
3 files changed, 7 insertions, 2 deletions
diff --git a/doc/telescope.txt b/doc/telescope.txt
index cd6602d..7eb6ead 100644
--- a/doc/telescope.txt
+++ b/doc/telescope.txt
@@ -646,6 +646,10 @@ builtin.man_pages({opts}) *builtin.man_pages()*
Parameters: ~
{opts} (table) options to pass to the picker
+ Fields: ~
+ {sections} (table) a list of sections to search, use `{ "ALL" }` to
+ search in all sections
+
builtin.reloader({opts}) *builtin.reloader()*
Lists lua modules and reloads them on `<cr>`
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index 1972265..e4b34e2 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -244,6 +244,7 @@ builtin.help_tags = require("telescope.builtin.internal").help_tags
--- Lists manpage entries, opens them in a help window on `<cr>`
---@param opts table: options to pass to the picker
+---@field sections table: a list of sections to search, use `{ "ALL" }` to search in all sections
builtin.man_pages = require("telescope.builtin.internal").man_pages
--- Lists lua modules and reloads them on `<cr>`
diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua
index feeaf79..2408366 100644
--- a/lua/telescope/previewers/buffer_previewer.lua
+++ b/lua/telescope/previewers/buffer_previewer.lua
@@ -505,14 +505,14 @@ previewers.man = defaulter(function(opts)
return previewers.new_buffer_previewer {
title = "Man Preview",
get_buffer_by_name = function(_, entry)
- return entry.value
+ return entry.value .. "/" .. entry.section
end,
define_preview = function(self, entry, status)
local win_width = vim.api.nvim_win_get_width(self.state.winid)
putils.job_maker({ "man", entry.section, entry.value }, self.state.bufnr, {
env = { ["PAGER"] = pager, ["MANWIDTH"] = win_width },
- value = entry.value,
+ value = entry.value .. "/" .. entry.section,
bufname = self.state.bufname,
})
putils.regex_highlighter(self.state.bufnr, "man")