Enable toggling terminal windows

This commit is contained in:
Andreas Wachs 2023-08-22 13:34:12 +02:00
parent 4e1eff9b87
commit d2382b9042
No known key found for this signature in database
GPG Key ID: 46FF84123E7DCEAC

View File

@ -1,52 +1,66 @@
return { return {
{ {
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
event = "VeryLazy", event = "VeryLazy",
cmd = { "ToggleTerm", "TermExec" }, cmd = { "ToggleTerm", "TermExec" },
config = function() config = function()
-- Lazygit local Terminal = require('toggleterm.terminal').Terminal
local Terminal = require('toggleterm.terminal').Terminal local defaultTerm = Terminal:new({ cmd = "zsh", hidden = true, direction = "float" })
local defaultTerm = Terminal:new({ cmd = "zsh", hidden = true, direction = "float" }) local lazygit = Terminal:new({ cmd = "lazygit", hidden = true, direction = "float" })
local lazygit = Terminal:new({ cmd = "lazygit", hidden = true, direction = "float" }) local pythonREPL = Terminal:new({ cmd = "python3", hidden = true, direction = "float" })
local pythonREPL = Terminal:new({ cmd = "python3", hidden = true, direction = "float" }) local haskellREPL = Terminal:new({ cmd = "ghci", hidden = true, direction = "float" })
local haskellREPL = Terminal:new({ cmd = "ghci", hidden = true, direction = "float" })
function _defaultterm_toggle() function _defaultterm_toggle()
defaultTerm:toggle() defaultTerm:toggle()
end end
function _lazygit_toggle() function _lazygit_toggle()
lazygit:toggle() lazygit:toggle()
end end
function _pythonREPL_toggle() function _pythonREPL_toggle()
pythonREPL:toggle() pythonREPL:toggle()
end end
function _haskellREPL_toggle() function _haskellREPL_toggle()
haskellREPL:toggle() haskellREPL:toggle()
end end
vim.keymap.set('n', '<space>tt', "<cmd>lua _defaultterm_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true }) function toggle_all()
vim.keymap.set('n', '<F7>', "<cmd>lua _defaultterm_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true }) if defaultTerm:is_open() then
vim.keymap.set('n', '<space>tl', "<cmd>lua _lazygit_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true }) defaultTerm:toggle()
vim.keymap.set('n', '<space>tp', "<cmd>lua _pythonREPL_toggle()<CR>", { desc = 'Toggle Python3 REPL', noremap = true, silent = true }) end
vim.keymap.set('n', '<space>th', "<cmd>lua _haskellREPL_toggle()<CR>", { desc = 'Toggle GHCI', noremap = true, silent = true }) if lazygit:is_open() then
end, lazygit:toggle()
opts = { end
size = 10, if pythonREPL:is_open() then
on_create = function() pythonREPL:toggle()
vim.opt.foldcolumn = "0" end
vim.opt.signcolumn = "no" if haskellREPL:is_open() then
end, haskellREPL:toggle()
open_mapping = [[<F7>]], end
shading_factor = 2, end
direction = "float",
float_opts = { vim.keymap.set('n', '<space>tt', "<cmd>lua _defaultterm_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true })
border = "curved", vim.keymap.set('n', '<F7>', "<cmd>lua _defaultterm_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true })
highlights = { border = "Normal", background = "Dark" }, vim.keymap.set('n', '<space>tl', "<cmd>lua _lazygit_toggle()<CR>", { desc = 'Toggle Lazygit', noremap = true, silent = true })
}, vim.keymap.set('n', '<space>tp', "<cmd>lua _pythonREPL_toggle()<CR>", { desc = 'Toggle Python3 REPL', noremap = true, silent = true })
vim.keymap.set('n', '<space>th', "<cmd>lua _haskellREPL_toggle()<CR>", { desc = 'Toggle GHCI', noremap = true, silent = true })
vim.keymap.set('t', '<C-l>', '<cmd>lua toggle_all()<CR>', { desc = 'Toggle all visible terminals' })
end,
opts = {
size = 10,
on_create = function()
vim.opt.foldcolumn = "0"
vim.opt.signcolumn = "no"
end,
open_mapping = [[<F7>]],
shading_factor = 2,
direction = "float",
float_opts = {
border = "curved",
highlights = { border = "Normal", background = "Dark" },
},
},
}, },
},
} }