local wk = require("which-key") wk.register({ ["sv"] = { "Reload Neovim configuration" }, ["p"] = { function () local file_path = vim.fn.expand("%") vim.fn.setreg("+", file_path) print("Copied \"" .. file_path .. "\" to clipboard.") end, "Copy relative file path to clipboard" }, [""] = { wk.show, "Show this help message" }, [""] = { vim.cmd.w, "Save buffer" }, ["t"] = { vim.cmd.tabnew, "Open a new tab" }, ["ix"] = { function () vim.o.expandtab = true end, "Change identation style to spaces" }, ["in"] = { function () vim.o.expandtab = false end, "Change identation style to tab" }, ['rw'] = { function () vim.cmd("%s/[ \\t]*$//g") vim.cmd.noh() end, 'Remove trailing whitespace' }, ["e"] = { vim.diagnostic.open_float, "Show diagnostics error details" }, ["n"] = { "Rename symbol under cursor" }, ["[d"] = { vim.diagnostic.goto_prev, "Go to previous diagnostics error" }, ["]d"] = { vim.diagnostic.goto_next, "Go to next diagnostics error" }, ["gD"] = { "Go to declaration" }, ["gd"] = { "Go to definition" }, ["dL"] = { "0D", "Truncate line" }, ["_"] = { function () local line = vim.fn.line(".") local last_line = vim.fn.line("$") if line ~= last_line then vim.cmd.m("+1") end end, "Move line down" }, ["-"] = { function () local line = vim.fn.line(".") if line ~= 1 then vim.cmd.m("-2") end end, "Move line up" }, ["H"] = { "0", "Same as 0" }, ["L"] = { "$", "Same as $" }, }, { mode = "n", silent = true, noremap = true }) wk.register({ [""] = { "", "Same as backspace" }, }, { mode = "i", silent = true, noremap = true, }) wk.register({ ["s\""] = { "``>a\"", "Surround with \"\"" }, ["s\'"] = { "``>a\'", "Surround with \'\'" }, ["s "] = { "``>a ", "Surround with space" }, ["s("] = { "``>a)", "Surround with ()" }, ["s)"] = { "``>a)", "Surround with ()" }, ["s["] = { "``>a]", "Surround with []" }, ["s]"] = { "``>a]", "Surround with []" }, ["s{"] = { "``>a}", "Surround with {}" }, ["s}"] = { "``>a}", "Surround with {}" }, ["J"] = { ":m '>+1gv=gv", "Move lines down" }, ["K"] = { ":m '<-2gv=gv", "Move lines up" }, ["y"] = { "\"+y", "Copy to system clipboard" }, }, { mode = "v", silent = true, noremap = true, })