File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -758,6 +758,29 @@ M.help = function(selected, opts)
758758 vim .cmd (" help " .. helptags (selected , opts )[1 ])
759759end
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+
761784M .help_vert = function (selected , opts )
762785 if # selected == 0 then return end
763786 vim .cmd (" vert help " .. helptags (selected , opts )[1 ])
Original file line number Diff line number Diff 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" ,
You can’t perform that action at this time.
0 commit comments