local M = {} function M.setup() local wk = require "which-key" wk.setup { plugins = { marks = false, registers = false, spelling = { enabled = false, suggestions = 20 }, presets = { operators = true, motions = true, text_objects = true, windows = true, nav = true, z = true, g = true, }, }, operators = { gc = "Comments" }, hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, popup_mappings = { scroll_down = "", scroll_up = "" }, ignore_missing = true, show_help = true, key_labels = { [""] = "SPC", [""] = "RET", [""] = "TAB" }, icons = { breadcrumb = "»", separator = "➜", group = "+" }, window = { border = "none", position = "bottom", margin = { 1, 0, 1, 0 }, padding = { 2, 2, 2, 2 }, winblend = 0, }, layout = { height = { min = 4, max = 25 }, width = { min = 20, max = 50 }, spacing = 3, align = "left", }, } local opts = { mode = "n", prefix = "", buffer = nil, silent = true, noremap = true, nowait = false, } local mappings = { f = { "Telescope find_files", "Find file" }, e = { "NvimTreeToggle", "File explorer" }, b = { "Telescope buffers", "Find buffer" }, w = { "write!", "Save file" }, q = { "quit!", "Quit" }, c = { "bdelete", "Close buffer" }, h = { "nohlsearch", "No hl" }, n = { "e! /tmp/note.md", "Note" }, s = { name = "Search", t = { "Telescope live_grep", "Live grep" }, r = { "Telescope oldfiles", "Find oldfile" }, b = { "Telescope git_branches", "Git branches" }, c = { "Telescope git_commits", "Git commits" }, s = { "Telescope spell_suggest", "Spell suggest" }, k = { "Telescope keymaps", "Find keymap" }, p = { "Telescope projects", "Projects" }, }, l = { name = "LSP", a = { "Telescope lsp_code_actions", "Code actions" }, d = { "TroubleToggle", "Diagnostics" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, f = { "lua vim.lsp.buf.formatting()", "Formatting" }, i = { "LspInfo", "Info" }, R = { "LspRestart", "Restart server" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, j = { "lua vim.diagnostic.goto_next()", "Next Diagnostic" }, q = { "lua vim.diagnostic.setloclist()", "Quickfix" }, k = { "lua vim.diagnostic.goto_prev()", "Prev Diagnostic" }, }, g = { name = "git", g = { "Neogit", "Neogit" }, s = { "lua require[[gitsigns]].stage_hunk()", "Stage hunk" }, r = { "lua require[[gitsigns]].reset_hunk()", "Reset hunk" }, p = { "lua require[[gitsigns]].preview_hunk()", "Preview hunk" }, b = { "lua require[[gitsigns]].blame_line(true)", "Blame line" }, R = { "lua require[[gitsigns]].reset_buffer()", "Reset buffer" }, S = { "lua require[[gitsigns]].stage_buffer()", "Stage buffer" }, }, p = { name = "Packer", s = { "PackerSync", "Sync" }, i = { "PackerInstall", "Install" }, c = { "PackerCompile", "Compile" }, C = { "PackerClean", "Clean" }, }, } wk.register(mappings, opts) end return M