From 2eaade0e236ec506000f8382a867b9d5056a7f47 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 27 Jul 2021 13:15:16 +0800 Subject: [PATCH] open the correct man page section --- lua/fzf-lua/providers/manpages.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lua/fzf-lua/providers/manpages.lua b/lua/fzf-lua/providers/manpages.lua index 679b7f9..d3ffb82 100644 --- a/lua/fzf-lua/providers/manpages.lua +++ b/lua/fzf-lua/providers/manpages.lua @@ -13,8 +13,17 @@ local actions = require "fzf-lua.actions" local M = {} local function getmanpage(line) - -- match until comma or space - return string.match(line, "[^, ]+") + -- extract section from the last pair of parentheses + local name, section = line:match("^(.*)%((.-)%)[^()]-$") + if name:sub(-1) == " " then + -- man-db + name = name:sub(1, -2) + else + -- mandoc + name = name:match("^[^, ]+") + section = section:match("^[^, ]+") + end + return name .. "(" .. section .. ")" end M.manpages = function(opts)