aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/toggleterm.lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-03-08 09:18:59 +0200
committersrdusr <trevorgray@srdusr.com>2023-03-08 09:18:59 +0200
commit25d5d4d39c9895702b01af56d14ca609cdd74fee (patch)
treea7dcb3685768c7e55fa7c5972179259257a3ad15 /.config/nvim/lua/plugins/toggleterm.lua
parent4c6d385b35c9a9e84224d8705864a0f72f7d1f90 (diff)
parent8c6b1a59acec18c2e4ec34fa586421b9ab7bd587 (diff)
downloaddotfiles-25d5d4d39c9895702b01af56d14ca609cdd74fee.tar.gz
dotfiles-25d5d4d39c9895702b01af56d14ca609cdd74fee.zip
Merge commit 'ea9278c7ef76f36503029667f8ed9a29abea0655'
Diffstat (limited to '.config/nvim/lua/plugins/toggleterm.lua')
-rw-r--r--.config/nvim/lua/plugins/toggleterm.lua26
1 files changed, 22 insertions, 4 deletions
diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua
index 5875fc6..a9bd450 100644
--- a/.config/nvim/lua/plugins/toggleterm.lua
+++ b/.config/nvim/lua/plugins/toggleterm.lua
@@ -2,7 +2,6 @@ local status_ok, toggleterm = pcall(require, "toggleterm")
if not status_ok then
return
end
-
toggleterm.setup({
--size = function(term)
-- if term.direction == "horizontal" then
@@ -13,6 +12,7 @@ toggleterm.setup({
--end,
--size = 20,
open_mapping = [[<leader>tt]],
+ --autochdir = true,
hide_numbers = true,
shade_filetypes = {},
shade_terminals = false,
@@ -77,12 +77,11 @@ end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
---vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()")
-
local Terminal = require("toggleterm.terminal").Terminal
local lazygit = Terminal:new({
cmd = "lazygit",
count = 5,
+ id = 1000,
dir = "git_dir",
direction = "float",
on_open = float_handler,
@@ -92,6 +91,7 @@ local lazygit = Terminal:new({
width = 150,
height = 40
},
+
---- Function to run on opening the terminal
--on_open = function(term)
-- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<CR>',
@@ -108,7 +108,25 @@ local lazygit = Terminal:new({
})
function Lazygit_toggle()
- lazygit:toggle()
+ -- cwd is the root of project. if cwd is changed, change the git.
+ local cwd = vim.fn.getcwd()
+ if cwd ~= Cur_cwd then
+ Cur_cwd = cwd
+ lazygit:close()
+ lazygit = Terminal:new({
+ cmd = "lazygit",
+ dir = "git_dir",
+ direction = "float",
+ hidden = true,
+ on_open = float_handler,
+ float_opts = {
+ border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' },
+ width = 150,
+ height = 40
+ },
+ })
+ end
+ lazygit:toggle()
end
local node = Terminal:new({ cmd = "node", hidden = true })