make sure we can exit dap terminal with esc
This commit is contained in:
@ -1,5 +1,15 @@
|
|||||||
dap = require('dap')
|
dap = require('dap')
|
||||||
|
|
||||||
|
|
||||||
|
-- make sure we can exit the terminal with esc
|
||||||
|
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||||
|
pattern = { '*dap-terminal*' },
|
||||||
|
callback = function()
|
||||||
|
local opts = { noremap = true }
|
||||||
|
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local function getVenvSuffix()
|
local function getVenvSuffix()
|
||||||
if vim.loop.os_uname().sysname == 'Linux' then
|
if vim.loop.os_uname().sysname == 'Linux' then
|
||||||
return 'bin/python'
|
return 'bin/python'
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
require('toggleterm').setup({})
|
|
||||||
|
function _G.set_terminal_keymaps(term)
|
||||||
|
local opts = { noremap = true }
|
||||||
|
if (term.cmd ~= 'lazygit') then
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<esc>', [[<C-\><C-n>]], opts)
|
||||||
|
end
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', 'jk', [[<C-\><C-n>]], opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
require('toggleterm').setup({
|
||||||
|
on_open = set_terminal_keymaps
|
||||||
|
})
|
||||||
|
|
||||||
local Terminal = require('toggleterm.terminal').Terminal
|
local Terminal = require('toggleterm.terminal').Terminal
|
||||||
|
|
||||||
function _G.set_terminal_keymaps()
|
|
||||||
local opts = { noremap = true }
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
|
||||||
pattern = { 'term://*' },
|
|
||||||
callback = function()
|
|
||||||
set_terminal_keymaps()
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
local lazygit = Terminal:new({
|
local lazygit = Terminal:new({
|
||||||
cmd = 'lazygit',
|
cmd = 'lazygit',
|
||||||
-- dir = vim.fn.getcwd(),
|
-- dir = vim.fn.getcwd(),
|
||||||
@ -26,7 +24,7 @@ local lazygit = Terminal:new({
|
|||||||
direction = 'float',
|
direction = 'float',
|
||||||
on_open = function(term)
|
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", "q", "<cmd>close<CR>", {noremap = true, silent = true})
|
||||||
vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<esc>', '<esc>', {noremap = true, silent = true})
|
-- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '<esc>', '<esc>', {noremap = true, silent = true})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user