TOGGLETERM

This commit is contained in:
clint 2023-03-23 01:35:06 -05:00
parent fcbbae48c2
commit dfd255c60d
2 changed files with 26 additions and 1 deletions

View File

@ -42,6 +42,8 @@ wk.register({
-- Debugging -- Debugging
D = "Debug UI", D = "Debug UI",
B = "Set Breakpoint", B = "Set Breakpoint",
["<F1>"] = "Open IPython",
["<F2>"] = "Execute py file",
["<F5>"] = "Debug: Continue", ["<F5>"] = "Debug: Continue",
}, },
}) })

View File

@ -82,4 +82,27 @@ keymap('n', '<F7>', ":lua require'dap'.step_over()<CR>", default_ops)
keymap('n', '<Leader>D', ":lua require'dapui'.toggle()<CR>", default_ops) keymap('n', '<Leader>D', ":lua require'dapui'.toggle()<CR>", default_ops)
-- REPL -- REPL
keymap('v', '<Leader>x', ':ToggleTermSendVisualLines<CR><CR>', default_ops) keymap('v', '<Leader>x', ':ToggleTermSendVisualLines 100<CR><CR>', default_ops)
-- Helpful stuff for ToggleTerm, taken from their docs
function _G.set_terminal_keymaps()
local opts = {buffer = 0}
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
-- Toggle a custom Terminal with ipython
local Terminal = require('toggleterm.terminal').Terminal
local ipython = Terminal:new({ cmd="ipython", direction="horizontal", count="100"})
function _ipython_toggle()
ipython:toggle()
end
keymap('n', '<F1>', ":lua _ipython_toggle()<CR><Cmd>wincmd k<CR>", default_ops)