use toggleterm for lazygit

This commit is contained in:
Oliver Hartmann 2024-05-22 09:02:29 +02:00
parent b8e9373c79
commit 3fe8d4f86d
2 changed files with 33 additions and 19 deletions

View File

@ -1,19 +0,0 @@
return {
'kdheepak/lazygit.nvim',
cmd = {
'LazyGit',
'LazyGitConfig',
'LazyGitFilter',
'LazyGitFilterCurrentFile',
'LazyGit',
},
keys = {
{
'<Space>g',
function()
require('lazygit').lazygit()
end,
desc = 'LazyGit'
}
}
}

View File

@ -18,7 +18,40 @@ return {
})
local Terminal = require('toggleterm.terminal').Terminal
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>', { noremap = true, silent = true })
end,
-- function to run on closing the terminal
on_close = function(term)
vim.cmd('startinsert!')
end,
})
function _lazygit_toggle()
lazygit:toggle()
end
vim.keymap.set('n', '<leader>g', function()
end,
{ noremap = true, silent = true })
end,
keys = {
{
'<Space>g',
function()
_lazygit_toggle()
end,
desc = 'LazyGit'
}
},
cmd = 'ToggleTerm',
}