diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-02-12 16:55:13 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-02-12 16:55:13 +0200 |
| commit | d69abfcf20866c4f8b275676cdcca605c53e02b1 (patch) | |
| tree | 727e8218d2900775959fce0add3be410f34d1ba9 /.config/nvim/lua/plugins/toggleterm.lua | |
| parent | 009cd3c349ada787d5828d69655c7cd78707ae40 (diff) | |
| parent | b10c2f1a3c45abf96194d73d5d546eef225dc06d (diff) | |
| download | dotfiles-d69abfcf20866c4f8b275676cdcca605c53e02b1.tar.gz dotfiles-d69abfcf20866c4f8b275676cdcca605c53e02b1.zip | |
Merge commit 'fb5d4420ee71f53c5550cf9217b54355d202c1a0'
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 + |
