local map = vim.keymap.set local function nmap(lhs, rhs, opts) map('n', lhs, rhs, opts) end local function swap(mode, bind1, bind2) local tmp=bind1 map(mode, bind1, bind2) map(mode, bind2, tmp) end local function swapnv(bind1, bind2) swap({'n', 'v'}, bind1, bind2) end swapnv('m', 'h') swapnv('n', 'j') swapnv('e', 'k') swapnv('i', 'l') swapnv('M', 'H') swapnv('N', 'J') --swapnv('E', 'K') swapnv('I', 'L') nmap('tn', ':tabnew', { desc = "Open a new tab" }) nmap('tc', ':tabc', { desc = "Close the current tab" }) nmap('tm', ':tabp', { desc = "Go to previous tab" }) nmap('ti', ':tabn', { desc = "Go to next tab" }) nmap('wh', ':vne', { desc = "Create vertical split" }) nmap('wv', ':new', { desc = "Create horizontal split" }) nmap('wc', ':clo', { desc = "Close current window" }) nmap('wm', '', { desc = "Focus window left of the current one" }) nmap('wn', '', { desc = "Focus window below the current one" }) nmap('we', '', { desc = "Focus window above the current one" }) nmap('wi', '', { desc = "Focus window right of the current one" }) -- nmap('', '', { desc = "Focus window left of the current one" }) -- nmap('', '', { desc = "Focus window below the current one" }) -- nmap('', '', { desc = "Focus window above the current one" }) -- nmap('', '', { desc = "Focus window right of the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_left() end, { desc = "Focus window left of the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_bottom() end, { desc = "Focus window below the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_top() end, { desc = "Focus window above the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_right() end, { desc = "Focus window right of the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_left() end, { desc = "Resize left side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_bottom() end, { desc = "Resize bottom side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_top() end, { desc = "Resize top side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_right() end, { desc = "Resize right side of split" }) -- nmap('fo', 'Telescope find_files', { silent = true }) nmap('fo', 'FzfLua files', { silent = true }) -- nmap('fe', 'lua require("oil").open(nil, { preview = { split = "aboveleft" } })', { silent = true }) nmap('fe', 'lua require("oil").toggle_float()', { silent = true }) -- nmap('?', 'Telescope live_grep', { silent = true }) nmap('?', 'FzfLua live_grep_native', { silent = true }) nmap('to', 'te', { silent = true; desc = "Open a terminal buffer in the current window." })