fixed which_key config

This commit is contained in:
2024-08-14 22:36:50 +05:00
parent 8c4913157f
commit 5dd8eaa3ac

View File

@ -14,7 +14,6 @@ which_key.setup({
-- the presets plugin, adds help for a bunch of default keybindings in Neovim -- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created -- No actual key bindings are created
presets = { presets = {
operators = false, -- adds help for operators like d, y, ...
motions = false, -- adds help for motions motions = false, -- adds help for motions
text_objects = false, -- help for text objects triggered after entering an operator text_objects = false, -- help for text objects triggered after entering an operator
windows = false, -- default bindings on <c-w> windows = false, -- default bindings on <c-w>
@ -25,24 +24,14 @@ which_key.setup({
}, },
-- add operators that will trigger motion and text object completion -- add operators that will trigger motion and text object completion
-- to enable all native operators, set the preset / operators plugin above -- to enable all native operators, set the preset / operators plugin above
operators = { gc = "Comments" }, win = {
key_labels = {
-- override the label used to display some keys. It doesn't effect WK in any other way.
-- For example:
-- ["<space>"] = "SPC",
-- ["<cr>"] = "RET",
-- ["<tab>"] = "TAB",
},
popup_mappings = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
window = {
border = "single", -- none, single, double, shadow border = "single", -- none, single, double, shadow
position = "bottom", -- bottom, top position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0, wo = {
winblend = 0,
}
}, },
layout = { layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns height = { min = 4, max = 25 }, -- min and max height of the columns
@ -50,19 +39,13 @@ which_key.setup({
spacing = 3, -- spacing between columns spacing = 3, -- spacing between columns
align = "left", -- align columns left, center or right 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 = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible 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 show_keys = true, -- show the currently pressed key and its label as a message in the command line
triggers = "auto", -- automatically setup triggers triggers = {
{ "<auto>", mode = "nxsot" },
},
-- triggers = {"<leader>"} -- or specify a list manually -- triggers = {"<leader>"} -- 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. -- disable the WhichKey popup for certain buf types and file types.
-- Disabled by default for Telescope -- Disabled by default for Telescope
disable = { disable = {
@ -71,121 +54,43 @@ which_key.setup({
}, },
}) })
which_key.register({ which_key.add({
name = "Hotkeys", { "<leader>", group = "Hotkeys" },
o = { { "<leader>F", ":lua vim.lsp.buf.format() <CR>", desc = "Format file" },
":Oil --float <CR>", { "<leader>c", group = "Code actions" },
"Oil nvim toggle", { "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", desc = "Show code actions" },
}, { "<leader>d", group = "DAP" },
e = { { "<leader>db", "<cmd>DapToggleBreakpoint<CR>", desc = "Toggle breakpoint" },
":Neotree toggle <CR>", { "<leader>dj", "<cmd>DapStepInto<CR>", desc = "StepInto" },
"File tree toggle", { "<leader>dk", "<cmd>DapStepOut<CR>", desc = "StepOut" },
}, { "<leader>dl", "<cmd>DapStepOver<CR>", desc = "StepOver" },
F = { { "<leader>dr", "<cmd>DapContinue<CR>", desc = "DapContinue" },
":lua vim.lsp.buf.format() <CR>", { "<leader>ds", "<cmd>DapTerminate<CR>", desc = "Terminate" },
"Format file", { "<leader>e", ":Neotree toggle <CR>", desc = "File tree toggle" },
}, { "<leader>f", group = "Find" },
f = { { "<leader>fb", "<cmd>lua require'telescope.builtin'.buffers()<cr>", desc = "Find buffer" },
name = "Find", { "<leader>ff", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", desc = "Find file" },
f = { { "<leader>fw", "<cmd>lua require'telescope.builtin'.live_grep()<cr>", desc = "Grep file" },
"<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", { "<leader>l", "<cmd>lua vim.diagnostic.setloclist()<CR>", desc = "Show diagnostic list" },
"Find file", { "<leader>o", ":Oil --float <CR>", desc = "Oil nvim toggle" },
}, { "<leader>t", group = "Tabs" },
w = { { "<leader>tn", "<cmd>tabnew<CR>", desc = "New tab" },
"<cmd>lua require'telescope.builtin'.live_grep()<cr>", { "<leader>tq", "<cmd>tabclose<CR>", desc = "Close tab" },
"Grep file", }
}, )
b = {
"<cmd>lua require'telescope.builtin'.buffers()<cr>",
"Find buffer",
},
},
c = {
name = "Code actions",
a = {
"<cmd>lua vim.lsp.buf.code_action()<CR>",
"Show code actions",
},
},
l = {
"<cmd>lua vim.diagnostic.setloclist()<CR>",
"Show diagnostic list",
},
d = {
name = "DAP",
r = {
"<cmd>DapContinue<CR>",
"DapContinue",
},
j = {
"<cmd>DapStepInto<CR>",
"StepInto",
},
l = {
"<cmd>DapStepOver<CR>",
"StepOver",
},
k = {
"<cmd>DapStepOut<CR>",
"StepOut",
},
b = {
"<cmd>DapToggleBreakpoint<CR>",
"Toggle breakpoint",
},
s = {
"<cmd>DapTerminate<CR>",
"Terminate",
},
},
t = {
name = "Tabs",
n = {
"<cmd>tabnew<CR>",
"New tab",
},
q = {
"<cmd>tabclose<CR>",
"Close tab",
},
},
}, { prefix = "<leader>" })
which_key.register({ which_key.add({
name = "LSP Actions", { "g", group = "LSP Actions" },
D = { { "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", desc = "Go to declaration" },
"<cmd>lua vim.lsp.buf.declaration()<CR>", { "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", desc = "Go to definition" },
"Go to declaration", { "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", desc = "Show implementations" },
}, { "gl", "<cmd>lua vim.diagnostic.open_float({ border = 'rounded' })<CR>", desc = "Show diagnostic at line" },
d = { { "gr", "<cmd>lua vim.lsp.buf.references()<CR>", desc = "Show references" },
"<cmd>lua vim.lsp.buf.definition()<CR>", { "grr", "<cmd>lua vim.lsp.buf.rename()<CR>", desc = "Rename" },
"Go to definition", }
}, )
i = {
"<cmd>lua vim.lsp.buf.implementation()<CR>",
"Show implementations",
},
rr = {
"<cmd>lua vim.lsp.buf.rename()<CR>",
"Rename",
},
r = {
"<cmd>lua vim.lsp.buf.references()<CR>",
"Show references",
},
l = {
"<cmd>lua vim.diagnostic.open_float({ border = 'rounded' })<CR>",
"Show diagnostic at line",
},
}, { prefix = "g" })
which_key.register({ which_key.add({
["<C-k>"] = { { "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", desc = "Signature help" },
"<cmd>lua vim.lsp.buf.signature_help()<CR>", { "K", "<cmd>lua vim.lsp.buf.hover()<CR>", desc = "Signature help" },
"Signature help", })
},
["K"] = {
"<cmd>lua vim.lsp.buf.hover()<CR>",
"Signature help",
},
}, {})