From d7b5400c976551a0d384e5fcbdcca1310d1a1aca Mon Sep 17 00:00:00 2001 From: Edward Litherland-Smith Date: Tue, 25 Oct 2022 09:37:27 +0100 Subject: [PATCH] Change lazygit/ranger to terminals with identifiers to stop closing existing terminals. Add keymaps to easily move out of terminals --- init.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 5522e1de..e38e280c 100644 --- a/init.lua +++ b/init.lua @@ -24,12 +24,23 @@ require('toggleterm').setup{ open_mapping = [[\t]], size = 20, hide_numbers = true, -- hide the number column in toggleterm buffers - direction = 'float', + persist_size = false, } +function _G.set_terminal_keymaps() + local opts = {buffer = 0} + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + local Terminal = require('toggleterm.terminal').Terminal -local lazygit = Terminal:new({ cmd = "lazygit", hidden = true, direction = 'float' }) -local ranger = Terminal:new({ cmd = "ranger", hidden = true, direction = 'float' }) +local lazygit = Terminal:new({ cmd = "lazygit", count = 99, direction = 'float' }) +local ranger = Terminal:new({ cmd = "ranger", count = 100, direction = 'float' }) function _lazygit_toggle() lazygit:toggle()