fix(nvim): ensure toggleterm exits when toggled
This commit is contained in:
parent
0a2c4f9d64
commit
de48802722
@ -2,7 +2,28 @@ return {
|
|||||||
{
|
{
|
||||||
"akinsho/toggleterm.nvim",
|
"akinsho/toggleterm.nvim",
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader><leader>", "<cmd>ToggleTerm<CR>", desc = "ToggleTerm: Toggle" },
|
{
|
||||||
|
"<leader><leader>",
|
||||||
|
function()
|
||||||
|
local mode = vim.fn.mode(1)
|
||||||
|
local curr_buffer = vim.api.nvim_buf_get_name(0)
|
||||||
|
local toggleterm_match = function(buf_name)
|
||||||
|
return buf_name:find("toggleterm#", 1, true)
|
||||||
|
end
|
||||||
|
if toggleterm_match(curr_buffer) then
|
||||||
|
-- Try to exit with toggleterm
|
||||||
|
vim.cmd.ToggleTerm()
|
||||||
|
|
||||||
|
-- We didn't successfully exit, use `q` to do so.
|
||||||
|
if toggleterm_match(vim.api.nvim_buf_get_name(0)) then
|
||||||
|
vim.cmd(":q")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
vim.cmd.ToggleTerm()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
desc = "ToggleTerm: Toggle"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
start_in_insert = false,
|
start_in_insert = false,
|
||||||
|
Loading…
Reference in New Issue
Block a user