style(toggleterm.lua): fix indentation and alignment for better readability

feat(toggleterm.lua): add lazygit terminal setup with custom configurations
feat(toggleterm.lua): add keymap to toggle lazygit terminal with leader key
feat(toggleterm.lua): comment out keymap for opening a general terminal
This commit is contained in:
David Ibia
2024-02-26 14:37:06 +01:00
parent dcabac3a07
commit ba39d9bfe4

View File

@@ -2,35 +2,35 @@ local toggle_term = require("toggleterm")
local Terminal = require("toggleterm.terminal").Terminal
toggle_term.setup({
direction = "float",
direction = "float",
})
local opts = { noremap = true, silent = true }
local lazygit = Terminal:new({
cmd = "lazygit",
dir = "git_dir",
direction = "float",
float_opts = {
border = "double",
},
-- function to run on opening the terminal
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", opts)
end,
-- function to run on closing the terminal
on_close = function(term)
vim.cmd("startinsert!")
end,
cmd = "lazygit",
dir = "git_dir",
direction = "float",
float_opts = {
border = "double",
},
-- function to run on opening the terminal
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", opts)
end,
-- function to run on closing the terminal
on_close = function(term)
vim.cmd("startinsert!")
end,
})
function _LAZYGIT_TOGGLE()
lazygit:toggle()
lazygit:toggle()
end
opts.desc = "Open lazygit"
vim.api.nvim_set_keymap("n", "<leader>gs", "<cmd>lua _LAZYGIT_TOGGLE()<CR>", opts)
opts.desc = "Open a terminal"
vim.api.nvim_set_keymap("n", "<C-`>", "<cmd>ToggleTerm<CR>", opts)
-- opts.desc = "Open a terminal"
-- vim.api.nvim_set_keymap("n", "<C-`>", "<cmd>ToggleTerm<CR>", opts)