Open Dioswilson opened 2 months ago
My fix was removing t
mode from my manual mappings. When I leave insert mode in ToggleTerm I can use my bindings.
But if that config above was your total config around ToggleTerm, then this won't help you.
before
vim.keymap.set({ "n", "t" }, "<leader>th", "<cmd>:1ToggleTerm direction=horizontal<CR>")
vim.keymap.set({ "n", "t" }, "<leader>tt", "<cmd>:2ToggleTerm direction=horizontal<CR>")
vim.keymap.set({ "n", "t" }, "<leader>tn", "<cmd>:3ToggleTerm direction=horizontal<CR>")
vim.keymap.set({ "n", "t" }, "<leader>ts", "<cmd>:4ToggleTerm direction=horizontal<CR>")
vim.keymap.set({ "n", "t" }, "<leader>tc", "<cmd>:ToggleTermToggleAll<CR>")
after
vim.keymap.set("n", "<leader>th", "<cmd>:1ToggleTerm direction=horizontal<CR>")
vim.keymap.set("n", "<leader>tt", "<cmd>:2ToggleTerm direction=horizontal<CR>")
vim.keymap.set("n", "<leader>tn", "<cmd>:3ToggleTerm direction=horizontal<CR>")
vim.keymap.set("n", "<leader>ts", "<cmd>:4ToggleTerm direction=horizontal<CR>")
vim.keymap.set("n", "<leader>tc", "<cmd>:ToggleTermToggleAll<CR>")
complete
return {
"akinsho/nvim-toggleterm.lua",
opts = {
auto_scroll = true,
close_on_exit = true,
hide_numbers = true,
insert_mappings = false, -- Relevant
persist_size = true,
shade_terminals = false,
start_in_insert = true,
terminal_mappings = false, -- Relevant
},
config = function(_, opts)
local toggle_term = require("toggleterm")
-- Windows
if vim.fn.has("win32") == 1 then
opts.shell_command = "pwsh.exe -NoLogo"
end
toggle_term.setup(opts)
vim.keymap.set(
"n",
"<leader>th",
"<CMD>:1ToggleTerm direction=horizontal<CR>",
{ desc = "ToggleTerm: Horizontal 1" }
)
vim.keymap.set(
"n",
"<leader>tt",
"<CMD>:2ToggleTerm direction=horizontal<CR>",
{ desc = "ToggleTerm: Horizontal 2" }
)
vim.keymap.set(
"n",
"<leader>tn",
"<CMD>:3ToggleTerm direction=horizontal<CR>",
{ desc = "ToggleTerm: Horizontal 3" }
)
vim.keymap.set(
"n",
"<leader>ts",
"<CMD>:4ToggleTerm direction=horizontal<CR>",
{ desc = "ToggleTerm: Horizontal 4" }
)
vim.keymap.set("n", "<leader>tc", "<CMD>:ToggleTermToggleAll<CR>", { desc = "ToggleTerm: Toggle All" })
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()")
end,
}
Is there an existing issue for this?
Current Behavior
I have this configuration:
with leader being spacebar, when hitting spacebar to separate words it keeps waiting for the next key and only option it apears in
which key
is toggle termExpected Behavior
insert_mappings=false
should prevent me from hitting<leader>t
to close the terminal while writingSteps To Reproduce
leader
<leader>t]
Environment
Anything else?
No response