From c959b2112fb4c82b5bfd410df21706455225bd40 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 3 Jul 2024 17:03:56 +0100 Subject: minor additions --- lua/config/which_key_config.lua | 272 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 lua/config/which_key_config.lua (limited to 'lua/config/which_key_config.lua') diff --git a/lua/config/which_key_config.lua b/lua/config/which_key_config.lua new file mode 100644 index 0000000..4083ebc --- /dev/null +++ b/lua/config/which_key_config.lua @@ -0,0 +1,272 @@ +local status_ok, which_key = pcall(require, "which-key") +if not status_ok then + return +end + +local setup = { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + spelling = { + enabled = true, + suggestions = 20, + }, -- use which-key for spelling hints + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = false, -- adds help for operators like d, y, ... + motions = true, -- adds help for motions + text_objects = true, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + }, + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + -- operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- [""] = "SPC", + -- [""] = "RET", + -- [""] = "TAB", + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "", -- symbol used between a key and it's label + group = "", -- symbol prepended to a group + }, + popup_mappings = { + scroll_down = "", -- binding to scroll down inside the popup + scroll_up = "", -- binding to scroll up inside the popup + }, + window = { + border = "single", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "left", -- align columns left, center or right + }, + ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + show_keys = true, -- show the currently pressed key and its label as a message in the command line + triggers = "auto", -- automatically setup triggers + -- triggers = {""} -- or specify a list manually + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + i = { "j", "k" }, + v = { "j", "k" }, + }, + -- disable the WhichKey popup for certain buf types and file types. + -- Disabled by default for Telescope + disable = { + buftypes = {}, + filetypes = { "TelescopePrompt" }, + }, + } + +local opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps + } + +-- local vopts = { +-- mode = "v", -- VISUAL mode +-- prefix = "", +-- buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings +-- silent = true, -- use `silent` when creating keymaps +-- noremap = true, -- use `noremap` when creating keymaps +-- nowait = true, -- use `nowait` when creating keymaps +-- } + + -- NOTE: Prefer using : over as the latter avoids going back in normal-mode. + -- see https://neovim.io/doc/user/map.html#:map-cmd +-- local vmappings = { +-- ["/"] = { "(comment_toggle_linewise_visual)", "Comment toggle linewise (visual)" }, +-- l = { +-- name = "LSP", +-- a = { "lua vim.lsp.buf.code_action()", "Code Action" }, +-- }, +-- g = { +-- name = "Git", +-- r = { "Gitsigns reset_hunk", "Reset Hunk" }, +-- s = { "Gitsigns stage_hunk", "Stage Hunk" }, +-- }, +-- } +-- +local mappings = { + [";"] = { "Alpha", "Dashboard" }, + ["w"] = { "w!", "Save" }, + ["q"] = { "confirm q", "Quit" }, + ["/"] = { "(comment_toggle_linewise_current)", "Comment toggle current line" }, + ["c"] = { "BufferKill", "Close Buffer" }, + ["h"] = { "nohlsearch", "No Highlight" }, + ["e"] = { "NvimTreeToggle", "Explorer" }, + ["v"] = { "edit /home/vgg/.config/nvim/init.lua", "Edit config" }, + b = { + name = "Buffers", + j = { "BufferLinePick", "Jump" }, + f = { "Telescope buffers previewer=false", "Find" }, + b = { "BufferLineCyclePrev", "Previous" }, + n = { "BufferLineCycleNext", "Next" }, + W = { "noautocmd w", "Save without formatting (noautocmd)" }, + -- w = { "BufferWipeout", "Wipeout" }, -- TODO: implement this for bufferline + e = { + "BufferLinePickClose", + "Pick which buffer to close", + }, + h = { "BufferLineCloseLeft", "Close all to the left" }, + l = { + "BufferLineCloseRight", + "Close all to the right", + }, + D = { + "BufferLineSortByDirectory", + "Sort by directory", + }, + L = { + "BufferLineSortByExtension", + "Sort by language", + }, + }, + d = { + name = "Debug", + t = { "lua require'dap'.toggle_breakpoint()", "Toggle Breakpoint" }, + b = { "lua require'dap'.step_back()", "Step Back" }, + c = { "lua require'dap'.continue()", "Continue" }, + C = { "lua require'dap'.run_to_cursor()", "Run To Cursor" }, + d = { "lua require'dap'.disconnect()", "Disconnect" }, + g = { "lua require'dap'.session()", "Get Session" }, + i = { "lua require'dap'.step_into()", "Step Into" }, + o = { "lua require'dap'.step_over()", "Step Over" }, + u = { "lua require'dap'.step_out()", "Step Out" }, + p = { "lua require'dap'.pause()", "Pause" }, + r = { "lua require'dap'.repl.toggle()", "Toggle Repl" }, + s = { "lua require'dap'.continue()", "Start" }, + q = { "lua require'dap'.close()", "Quit" }, + U = { "lua require'dapui'.toggle({reset = true})", "Toggle UI" }, + }, + p = { + name = "Plugins", + i = { "Lazy install", "Install" }, + s = { "Lazy sync", "Sync" }, + S = { "Lazy clear", "Status" }, + c = { "Lazy clean", "Clean" }, + u = { "Lazy update", "Update" }, + p = { "Lazy profile", "Profile" }, + l = { "Lazy log", "Log" }, + d = { "Lazy debug", "Debug" }, + }, +-- +-- -- -- " Available Debug Adapters: +-- -- -- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ +-- -- -- " Adapter configuration and installation instructions: +-- -- -- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation +-- -- -- " Debug Adapter protocol: +-- -- -- " https://microsoft.github.io/debug-adapter-protocol/ +-- -- -- " Debugging +-- ---- g = { +-- ---- name = "Git", +-- ---- j = { "lua require 'gitsigns'.nav_hunk('next', {navigation_message = false})", "Next Hunk" }, +-- ---- k = { "lua require 'gitsigns'.nav_hunk('prev', {navigation_message = false})", "Prev Hunk" }, +-- ---- l = { "lua require 'gitsigns'.blame_line()", "Blame" }, +-- ---- L = { "lua require 'gitsigns'.blame_line({full=true})", "Blame Line (full)" }, +-- ---- p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, +-- ---- r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, +-- ---- R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, +-- ---- s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, +-- ---- u = { +-- ---- "lua require 'gitsigns'.undo_stage_hunk()", +-- ---- "Undo Stage Hunk", +-- ---- }, +-- ---- o = { "Telescope git_status", "Open changed file" }, +-- ---- b = { "Telescope git_branches", "Checkout branch" }, +-- ---- c = { "Telescope git_commits", "Checkout commit" }, +-- ---- C = { +-- ---- "Telescope git_bcommits", +-- ---- "Checkout commit(for current file)", +-- ---- }, +-- ---- d = { +-- ---- "Gitsigns diffthis HEAD", +-- ---- "Git Diff", +-- ---- }, +-- ---- }, + l = { + name = "LSP", + a = { "lua vim.lsp.buf.code_action()", "Code Action" }, + d = { "Telescope diagnostics bufnr=0 theme=get_ivy", "Buffer Diagnostics" }, + w = { "Telescope diagnostics", "Diagnostics" }, + i = { "LspInfo", "Info" }, + I = { "Mason", "Mason Info" }, + j = { + "lua vim.diagnostic.goto_next()", + "Next Diagnostic", + }, + k = { + "lua vim.diagnostic.goto_prev()", + "Prev Diagnostic", + }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + q = { "lua vim.diagnostic.setloclist()", "Quickfix" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { + "Telescope lsp_dynamic_workspace_symbols", + "Workspace Symbols", + }, + e = { "Telescope quickfix", "Telescope Quickfix" }, + }, + s = { + name = "Search", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + f = { "Telescope find_files", "Find File" }, + h = { "Telescope help_tags", "Find Help" }, + H = { "Telescope highlights", "Find highlight groups" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "Telescope oldfiles", "Open Recent File" }, + R = { "Telescope registers", "Registers" }, + t = { "Telescope live_grep", "Text" }, + k = { "Telescope keymaps", "Keymaps" }, + C = { "Telescope commands", "Commands" }, + l = { "Telescope resume", "Resume last search" }, + p = { + "lua require('telescope.builtin').colorscheme({enable_preview = true})", + "Colorscheme with Preview", + }, + }, + T = { + name = "Treesitter", + i = { ":TSConfigInfo", "Info" }, + }, + t = { + name = "Terminal", + t = { "terminal", "Terminal" }, + g = { "lua require 'user.terminal'.lazygit_toggle()", "LazyGit" }, + i = { "lua require 'user.terminal'.ipython_toggle()", "IPython" }, + s = { "lua require 'user.terminal'.scim_toggle()", "sc-im" }, + w = { "lua require 'user.terminal'.w3m_toggle()", "w3m" }, + } + + + + }, + + which_key.setup(setup) + which_key.register(mappings, opts) +-- which_key.register(vmappings, vopts) -- cgit v1.2.3