1local key = require("gabrielgio.key")
2
3require("toggleterm").setup()
4
5local function isempty(s)
6 return s == nil or s == ""
7end
8
9local lastCommand = ""
10
11key.nnoremap("<C-n>", ":Neogit kind=replace<cr>")
12key.nnoremap("<C-p>", ":ToggleTerm size=40 direction=float<cr>")
13key.nnoremap("<C-l>", ":ToggleTerm size=100 direction=vertical<cr>")
14key.vnoremap("<C-y>", ":ToggleTermSendVisualSelection<cr>")
15key.nnoremap("<C-y>", function()
16 local user_input = vim.fn.input("$ ")
17
18 if isempty(user_input) then
19 user_input = lastCommand
20 end
21
22 if not isempty(user_input) then
23 vim.cmd(string.format("TermExec cmd='%s'", user_input))
24 lastCommand = user_input
25 end
26end)
27key.tnoremap("<Esc>", "<C-\\><C-n>")
28key.tnoremap("<C-p>", "<C-\\><C-n>:ToggleTerm<cr>")
29key.tnoremap("<C-l>", "<C-\\><C-n>:ToggleTerm<cr>")