mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 19:50:38 +00:00
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
37 lines
873 B
Lua
37 lines
873 B
Lua
local toggle_term = require("toggleterm")
|
|
local Terminal = require("toggleterm.terminal").Terminal
|
|
|
|
toggle_term.setup({
|
|
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,
|
|
})
|
|
|
|
function _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)
|