From a2211292a7ea5abac0801ab053832d41c56eaab4 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 18 Nov 2022 00:09:51 +0100 Subject: [PATCH] fix: allow to easily exit terminal mode --- configs/nvim/lua/core/keymappings.lua | 5 +++- configs/nvim/lua/overlays.lua | 34 +++++++-------------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/configs/nvim/lua/core/keymappings.lua b/configs/nvim/lua/core/keymappings.lua index c686288..6e48bbb 100644 --- a/configs/nvim/lua/core/keymappings.lua +++ b/configs/nvim/lua/core/keymappings.lua @@ -7,10 +7,13 @@ local saga = require("lspsaga") saga.init_lsp_saga() local options = { noremap = true, silent = true } -local remap = { noremap = false } +local remap = { noremap = true } g.mapleader = " " +-- Allows to easily exit terminal mode +map('t', '', [[]], remap) + map("n", "", ":Telescope find_files", options) map("n", "", ":lua require'telescope.builtin'.live_grep{ cwd = vim.fn.getcwd() }", options) -- map("n", "", ":Telescope command_center", options) diff --git a/configs/nvim/lua/overlays.lua b/configs/nvim/lua/overlays.lua index 09ad92e..17b3d9c 100644 --- a/configs/nvim/lua/overlays.lua +++ b/configs/nvim/lua/overlays.lua @@ -1,7 +1,5 @@ local Terminal = require("toggleterm.terminal").Terminal -local lazygit = -Terminal:new( - { +local lazygit = Terminal:new({ cmd = "lazygit", dir = "git_dir", direction = "float", @@ -9,15 +7,10 @@ Terminal:new( winblend = 0, border = "shadow" }, - on_open = function(term) - vim.cmd("startinsert!") - vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "close", { noremap = true, silent = true }) - end, on_close = function() Terminal:close() end -} -) +}) function _Lazygit_toggle() lazygit:toggle() @@ -25,18 +18,12 @@ end vim.api.nvim_set_keymap("n", "", "lua _Lazygit_toggle()", { noremap = true, silent = true }) -local pnpm = -Terminal:new( - { +local pnpm = Terminal:new({ cmd = "pnpm dev", dir = "git_dir", size = 5, - direction = "vertical", - on_close = function(term) - Terminal:close() - end -} -) + direction = "vertical" +}) function _Pnpm_toggle() pnpm:toggle() @@ -44,19 +31,16 @@ end vim.api.nvim_set_keymap("n", "d", "lua _Pnpm_toggle()", { noremap = true, silent = true }) -local chtConfig = -Terminal:new( - { +local chtConfig = Terminal:new({ cmd = "cht", direction = "float" -} -) +}) -function _chtConfig_toggle() +function _ChtConfig_toggle() chtConfig:toggle() end -vim.api.nvim_set_keymap("n", "", "lua _chtConfig_toggle()", { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "", "lua _ChtConfig_toggle()", { noremap = true, silent = true }) require("toggleterm").setup { shade_terminals = true