diff options
| author | JINNOUCHI Yasushi <me@delphinus.dev> | 2021-02-02 21:23:37 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-02 13:23:37 +0100 |
| commit | c422d86eb9c262606534754b5f4ee79bd01ae09a (patch) | |
| tree | 9fb76bcebbddb1b234f4ba60c35f1458691b9f21 /lua/telescope/make_entry.lua | |
| parent | 9e76b1613a25cc6f63d17eb73432523924662619 (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/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index d23dcb7..b0d8060 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -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 |
