akinsho/toggleterm.nvim

[Feature] add an option to prevent auto-closing float terminal on leaving the window

Open

#420 创建于 2023年3月30日

在 GitHub 查看
 (2 评论) (1 反应) (0 负责人)Lua (203 fork)batch import
difficulty: easyenhancementhelp wanted

仓库指标

Star
 (5,501 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Current implementation is auto close term when switch from a float terminal. I found the implementation is in toggleterm.lua:

local function handle_term_leave()
  local _, term = terms.identify()
  if not term then return end
  if config.persist_mode then term:persist_mode() end
  if term:is_float() then term:close() end
end

And there is no option or callback can be used to disable this behavior.

But sometimes auto-close float terminal is not the best choice. For example, if I use a float terminal to compile or do some test job, if has error, I want to switch to code buffer to fix it without closing terminal since I need refer the output of terminal, like below:

image

If I use terminal in the middle of the screen, auto close terminal for switching is reasonable. But if I use float terminal on the top-right or bottom-right of the screen, auto-closing is not necessary, and in most user cases, it should be disabled.

Could you please considering to add an option flag to prevent this default behavior, so it can fit different strategy and requirement.

Thank you.

贡献者指南