diff options
Diffstat (limited to '.config/nvim/lua/plugins/toggleterm.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/toggleterm.lua | 71 |
1 files changed, 59 insertions, 12 deletions
diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua index 0c3c45f..024c2f6 100644 --- a/.config/nvim/lua/plugins/toggleterm.lua +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -4,13 +4,13 @@ if not status_ok then end toggleterm.setup({ - size = function(term) - if term.direction == "horizontal" then - return 12 - elseif term.direction == "vertical" then - return vim.o.columns * 0.3 - end - end, + --size = function(term) + -- if term.direction == "horizontal" then + -- return 12 + -- elseif term.direction == "vertical" then + -- return vim.o.columns * 0.3 + -- end + --end, --size = 20, open_mapping = [[<leader>tt]], hide_numbers = true, @@ -31,7 +31,18 @@ toggleterm.setup({ Normal = { background = "#000000", }, - }, + --float_opts = { + -- border = as.style.current.border, + -- winblend = 3, + --}, + size = function(term) + if term.direction == 'horizontal' then + return 15 + elseif term.direction == 'vertical' then + return math.floor(vim.o.columns * 0.4) + end + end, + }, float_opts = { width = 70, height = 15, @@ -44,6 +55,14 @@ toggleterm.setup({ }, }, }) +local utils = require("user.utils") +local float_handler = function(term) + + if not utils.empty(vim.fn.mapcheck('jj', 't')) then + vim.keymap.del('t', 'jj', { buffer = term.bufnr }) + vim.keymap.del('t', '<esc>', { buffer = term.bufnr }) + end +end function _G.set_terminal_keymaps() local opts = { noremap = true } @@ -56,13 +75,40 @@ function _G.set_terminal_keymaps() vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts) end -vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") +-- 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", hidden = true }) +local lazygit = Terminal:new({ + cmd = "lazygit", + count = 5, + dir = "git_dir", + direction = "float", + on_open = float_handler, + hidden = true, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + 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>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<esc>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<C-\\>', '<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() +function Lazygit_toggle() + lazygit:toggle() end local node = Terminal:new({ cmd = "node", hidden = true }) @@ -88,3 +134,4 @@ local python = Terminal:new({ cmd = "python", hidden = true }) function _PYTHON_TOGGLE() python:toggle() end + |
