diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index e18d299..dd1d3e0 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -18,26 +18,28 @@ return { }) local Terminal = require('toggleterm.terminal').Terminal - local lazygit = Terminal:new({ - cmd = 'lazygit', - dir = vim.fn.getcwd(), - 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', 'close', { 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() + local lazygit = Terminal:new({ + cmd = 'lazygit', + direction = 'float', + cwd = function() + return vim.fn.getcwd() + end, + 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', 'close', { noremap = true, silent = true }) + end, + -- function to run on closing the terminal + on_close = function(term) + vim.cmd('startinsert!') + end, + }) + lazygit:open() end end, keys = {