Skip to content

Commit a13c5c5

Browse files
Tae Selene Sandoval Murganibhagwan
authored andcommitted
feat(helptags): open help in current win
1 parent 4333179 commit a13c5c5

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lua/fzf-lua/actions.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,29 @@ M.help = function(selected, opts)
758758
vim.cmd("help " .. helptags(selected, opts)[1])
759759
end
760760

761+
M.help_curwin = function(selected, opts)
762+
if #selected == 0 then return end
763+
local helpcmd
764+
local is_shown = false
765+
local current_win_number = 1
766+
local last_win_number = vim.fn.winnr("$")
767+
while current_win_number <= last_win_number do
768+
local buffer = vim.api.nvim_win_get_buf(vim.fn.win_getid(current_win_number))
769+
local type = vim.api.nvim_get_option_value("buftype", { buf = buffer })
770+
if type == "help" then
771+
is_shown = true
772+
break
773+
end
774+
current_win_number = current_win_number + 1
775+
end
776+
if is_shown then
777+
helpcmd = "help "
778+
else
779+
helpcmd = "enew | setlocal bufhidden=wipe | setlocal buftype=help | keepjumps help "
780+
end
781+
vim.cmd(helpcmd .. helptags(selected, opts)[1])
782+
end
783+
761784
M.help_vert = function(selected, opts)
762785
if #selected == 0 then return end
763786
vim.cmd("vert help " .. helptags(selected, opts)[1])

lua/fzf-lua/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ M._action_to_helpstr = {
10721072
[actions.help] = "help-open",
10731073
[actions.help_vert] = "help-vertical",
10741074
[actions.help_tab] = "help-tab",
1075+
[actions.help_curwin] = "help-open-curwin",
10751076
[actions.man] = "man-open",
10761077
[actions.man_vert] = "man-vertical",
10771078
[actions.man_tab] = "man-tab",

0 commit comments

Comments
 (0)