fix: allow to easily exit terminal mode

This commit is contained in:
max_richter 2022-11-18 00:09:51 +01:00
parent 13407572ac
commit a2211292a7
2 changed files with 13 additions and 26 deletions

View File

@ -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', '<Esc>', [[<C-\><C-n>]], remap)
map("n", "<C-o>", ":Telescope find_files<CR>", options)
map("n", "<C-f>", ":lua require'telescope.builtin'.live_grep{ cwd = vim.fn.getcwd() }<CR>", options)
-- map("n", "<C-p>", ":Telescope command_center<CR>", options)

View File

@ -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", "<cmd>close<CR>", { 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", "<C-g>", "<cmd>lua _Lazygit_toggle()<CR>", { 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", "<Leader>d", "<cmd>lua _Pnpm_toggle()<CR>", { 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", "<Leader><C-l>", "<cmd>lua _chtConfig_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<Leader><C-l>", "<cmd>lua _ChtConfig_toggle()<CR>", { noremap = true, silent = true })
require("toggleterm").setup {
shade_terminals = true