fix: preview the correct man page section (#1076)

This commit is contained in:
zeertzjq
2021-08-05 04:19:39 +08:00
committed by GitHub
parent aa7c13ea36
commit 654903fc04
3 changed files with 7 additions and 2 deletions

View File

@@ -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>`

View File

@@ -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>`

View File

@@ -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")