local status_ok, which_key = pcall(require, "which-key") if not status_ok then return end -- config for toggleterm function _SET_TAB_TITLE() -- set tab title vim.cmd('silent !wezterm cli set-tab-title "' .. require("user.utils")._get_folder_name() .. '"') end local icons = require("user.icons") local setup = { plugins = { marks = false, -- shows a list of your marks on ' and ` registers = false, -- 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 = false, -- adds help for motions text_objects = false, -- help for text objects triggered after entering an operator windows = false, -- default bindings on nav = false, -- misc bindings to work with windows z = false, -- bindings for folds, spelling and others prefixed with z g = false, -- 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 = icons.ui.DoubleChevronRight, -- symbol used in the command line area that shows your active key combo separator = icons.ui.BoldArrowRight, -- symbol used between a key and it's label group = icons.ui.Plus, -- 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 = "rounded", -- none, single, double, shadow position = "bottom", -- bottom, top margin = { 1, 1, 1, 1 }, -- 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" }, }, -- 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 opts2 = { mode = "v", -- 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 } -- for debug local debug_key = {} if vim.fn.has("win32") == 0 then debug_key = { 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" }, } end -- end debug local mappings2 = { ["/"] = { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", " 󰆈 Commet Block" }, } local mappings = { ["a"] = { "Alpha", "󰕮 Alpha" }, ["e"] = { "NvimTreeToggle", "󰙅 Explorer" }, ["w"] = { "w!", "󰆓 Save" }, ["q"] = { "q!", "󰿅 Quit" }, -- open exloler and close toggleterm ["o"] = { "lua require('user.utils')._OPEN_EXPLORER()", "󱏒 Open Explorer", }, ["h"] = { "nohlsearch", "󱪿 No Highlight" }, ["f"] = { "Telescope find_files ", " Find files", }, ["F"] = { "Telescope live_grep theme=ivy", " Find Text" }, ["/"] = { function() require("Comment.api").toggle.linewise.current() end, "󰆈 Coment line", }, b = { name = "  Buffers", -- show all buffers with telescope b = { "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", "All Buffer", }, -- close current active buffer c = { "lua require('user.utils').bufremove()", "Close current buffer" }, -- bufferline close left d = { "BufferLineCloseLeft", "Buffer close left", }, -- bufferline close right D = { "BufferLineCloseRight", "Buffer close right", }, -- bufferline close others a = { "BufferLineCloseOthers", "Buffer close others", }, -- close all bufferline A = { "BufferLineCloseOthersbd!", "Buffer close All Buffer", }, }, g = { name = "  Git", g = { "lua require('user.utils')._LAZYGIT_TOGGLE()", "Lazygit" }, j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, l = { "lua require 'gitsigns'.blame_line()", "Blame" }, 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" }, d = { "Gitsigns diffthis HEAD", "Diff", }, }, l = { name = "  LSP", a = { "lua vim.lsp.buf.code_action()", "Code Action" }, d = { "Telescope diagnostics bufnr=0", "Document Diagnostics", }, w = { "Telescope diagnostics", "Workspace Diagnostics", }, f = { "lua vim.lsp.buf.format{async=true}", "Format" }, i = { "LspInfo", "Info" }, I = { "Mason", "Installer Info" }, j = { "lua vim.lsp.diagnostic.goto_next()", "Next Diagnostic", }, k = { "lua vim.lsp.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", }, }, s = { name = "  Search", b = { "Telescope git_branches", "Checkout branch" }, c = { "Telescope colorscheme", "Colorscheme" }, h = { "Telescope help_tags", "Find Help" }, M = { "Telescope man_pages", "Man Pages" }, r = { "Telescope oldfiles", "Open Recent File" }, R = { "Telescope registers", "Registers" }, k = { "Telescope keymaps", "Keymaps" }, C = { "Telescope commands", "Commands" }, }, t = { name = "  Terminal", l = { "terminal live-server", "Live Server" }, P = { "lua require('user.utils')._NEWTAB_TOGGLE()", "Power Shell" }, x = { "ToggleTermToggleAll!", "Close Tab" }, n = { "lua require('user.utils')._NODE_TOGGLE()", "Node" }, b = { "lua require('user.utils')._BTOP_TOGGLE()", "Btop" }, p = { "lua require('user.utils')._PYTHON_TOGGLE()", "Python" }, f = { "ToggleTerm direction=float", "Float" }, h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, s = { "ToggleTerm direction=tab", "New Tab" }, a = { "lua require('user.utils')._OPEN_ALACRITTY()", "Open Alacritty" }, w = { "lua require('user.utils')._OPEN_WEZTERM()", "Open Wezterm" }, t = { "lua require('user.utils')._OPEN_WEZTERM_TAB()", "Open Tab Wezterm" }, j = { "lua _SET_TAB_TITLE()", "Set Tab Title" }, }, r = { name = "  Run", l = { "edit term://live-server", "Live Server" }, s = { 'autocmd bufwritepost [^_]*.sass,[^_]*.scss silent exec "!sass %:p %:r.css"', "Auto Compile Sass", }, r = { "RunCode", "Run Code" }, f = { "RunFile", "Run File" }, p = { "RunProject", "Run Project" }, g = { "terminalgradle run", "Run Gradle" }, m = { "terminal mvn package", "MVN Build", }, }, d = debug_key, z = { name = " 󱑠 Plugins(Lazy)", 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" }, }, } local wkey = {} local data_exists, key = pcall(require, "core.config") if data_exists then wkey = key.whichkey end which_key.setup(setup) which_key.register(mappings, opts) which_key.register(wkey, opts) which_key.register(mappings2, opts2)