add mapping for escaping terminal

This commit is contained in:
siduck 2022-05-14 16:23:02 +05:30
parent 0369a8ad77
commit ef27ad4f2d
2 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,9 @@
-- n, v, i are mode names -- n, v, i are mode names
local function termcodes(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local M = {} local M = {}
M.general = { M.general = {
@ -46,6 +50,10 @@ M.general = {
" toggle theme", " toggle theme",
}, },
}, },
t = {
["jk"] = { termcodes "<C-\\><C-N>", " escape terminal mode" },
},
} }
M.bufferline = { M.bufferline = {
@ -312,16 +320,18 @@ M.whichkey = {
n = { n = {
["<leader>wK"] = { ["<leader>wK"] = {
function() function()
vim.cmd("WhichKey") vim.cmd "WhichKey"
end, " which-key all keymaps", end,
" which-key all keymaps",
}, },
["<leader>wk"] = { ["<leader>wk"] = {
function() function()
local input = vim.fn.input("WhichKey: ") local input = vim.fn.input "WhichKey: "
vim.cmd("WhichKey " .. input) vim.cmd("WhichKey " .. input)
end, " which-key query lookup", end,
" which-key query lookup",
},
}, },
}
} }
return M return M

View File

@ -225,8 +225,5 @@ M.misc_mappings = function()
map("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) map("", "k", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
map("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true }) map("", "<Down>", 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', { expr = true })
map("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true }) map("", "<Up>", 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', { expr = true })
-- esscape from terminal mode
map("t", "jk", "<C-\\><C-n>")
end end
return M return M