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
This commit is contained in:
committed by
GitHub
parent
9e76b1613a
commit
c422d86eb9
@@ -613,9 +613,14 @@ function make_entry.gen_from_packages(opts)
|
||||
end
|
||||
end
|
||||
|
||||
function make_entry.gen_from_apropos()
|
||||
function make_entry.gen_from_apropos(opts)
|
||||
local sections = {}
|
||||
for _, section in ipairs(opts.sections) do
|
||||
sections[section] = true
|
||||
end
|
||||
|
||||
local displayer = entry_display.create {
|
||||
separator = "",
|
||||
separator = ' ',
|
||||
items = {
|
||||
{ width = 30 },
|
||||
{ remaining = true },
|
||||
@@ -624,20 +629,21 @@ function make_entry.gen_from_apropos()
|
||||
|
||||
local make_display = function(entry)
|
||||
return displayer {
|
||||
entry.value,
|
||||
{ entry.keyword, 'TelescopeResultsFunction' },
|
||||
entry.description
|
||||
}
|
||||
end
|
||||
|
||||
return function(line)
|
||||
local cmd, _, desc = line:match("^(.*)%s+%((.*)%)%s+%-%s(.*)$")
|
||||
|
||||
return {
|
||||
local keyword, cmd, section, desc = line:match'^((.-)%s*%(([^)]+)%).-)%s+%-%s+(.*)$'
|
||||
return keyword and sections[section] and {
|
||||
value = cmd,
|
||||
description = desc,
|
||||
ordinal = cmd,
|
||||
display = make_display,
|
||||
}
|
||||
section = section,
|
||||
keyword = keyword,
|
||||
} or nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user