-- Remap space as leader key vim.keymap.set("", "", "", { silent = true }) vim.g.mapleader = " " vim.g.maplocalleader = " " -- Modes test -- normal_mode = "n", -- insert_mode = "i", -- visual_mode = "v", -- visual_block_mode = "x", -- term_mode = "t", -- command_mode = "c", local nvx = { "n", "v", "x" } -- TODO remove this notify and replace with a once I have trained well enough local hjklNotid = nil local hjklNotification = function() hjklNotid = vim.notify("use h/j/k/l to move", 4, { replace = hjklNotid }) end U.keymaps({ -- Basic { "", hjklNotification, mode = { "n", "v", "x", "i" } }, { "", hjklNotification, mode = { "n", "v", "x", "i" } }, { "", hjklNotification, mode = { "n", "v", "x", "i" } }, { "", hjklNotification, mode = { "n", "v", "x", "i" } }, { ";", ":", desc = "No shift to enter command mode with semicolon. Alias ; to :", mode = nvx }, { "Q", "", mode = nvx }, -- don't do normal Q quit { "a", "ggVG", desc = "Select all", mode = nvx }, { "Q", "SessionSaveqa", desc = "Quit all", mode = nvx }, { "y", '"+y', desc = "Copy to system clipboard", mode = nvx }, { "p", '"+p', desc = "Paste from system clipboard", mode = nvx }, { "", "nohlsearch", desc = "Clear search on escape" }, { "", "nohlsearch", desc = "Clear search on return" }, { "|", "vsplit", desc = "Vertical Split" }, { "\\", "split", desc = "Horizontal Split" }, { "", "", desc = "Go back " }, { "J", ":m '>+1gv=gv", desc = "Visually move block down", mode = "v", }, { "K", ":m '<-2gv=gv", desc = "Visually move block up", mode = "v", }, { "", "", desc = "Escape the terminal", mode = "t" }, { "", "zz", desc = "Vertical half page down and center cursor" }, { "", "zz", desc = "Vertical half page up and center cursor" }, -- Buffers { "b", "b#", desc = "Switch to last buffer", mode = nvx }, { "q", function() -- Custom close/quituto -- -- * if non empty buffer, we will simply open a new empty buffer unless -- it is in the close always list -- * if empty buffer, then we will quit this buffer local close_always = { "quickfix", "help", "nofile", "noice", "httpResult" } if U.table_contains(close_always, vim.bo.buftype) or (vim.api.nvim_buf_line_count(0) == 1 and vim.api.nvim_buf_get_lines(0, 0, 1, -1)[1] == "") then vim.cmd("silent confirm q") else vim.cmd("enew") end end, desc = "Quit/Close current", mode = nvx, }, { "S", "set equalalwaysset noequalalways", desc = "Equalize/resize screens evenly", mode = nvx, }, { "", "h", desc = "Move window left current", mode = nvx }, { "", "j", desc = "Move window below current", mode = nvx }, { "", "k", desc = "Move window above current", mode = nvx }, { "", "l", desc = "Move window right current", mode = nvx }, -- Editor { "J", "mzJ`z", desc = "Move line below onto this line" }, { "]d", vim.diagnostic.goto_next, desc = "Go to next diagnostic message", }, { "[d", vim.diagnostic.goto_prev, desc = "Go to previous diagnostic message", }, { ">", "> gv", desc = "Indent selection", mode = "v" }, { "<", "< gv", desc = "Outdent selection", mode = "v" }, { "p", '"_dP', desc = "Paste without yanking replaced content", mode = "v" }, -- TODO take r from http requests? { "", '"hy:%s/h//g', desc = "Replace current selection", mode = "v" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, { "", "", mode = { "i", "c" }, desc = "Movements in insert/command mode" }, -- Tabs { "tn", "tabnew", desc = "Create new tab", mode = nvx }, { "tq", "tabclose", desc = "Close current tab", mode = nvx }, { "H", "tabprevious", desc = "Move to previous tab" }, { "L", "tabnext", desc = "Move to next tab" }, -- LSP/IDE/ { "ld", vim.diagnostic.open_float, desc = "Show diagnostic message", mode = nvx, }, { "ll", vim.diagnostic.setloclist, desc = "Show diagnostics in quickfix list", mode = nvx, }, })