-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving to current which-key version to v1.6.0
Also added customization to which key popup. The conversion to the earlier is because of ease of configurating which-key
- Loading branch information
Showing
2 changed files
with
161 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,166 @@ | ||
local status_ok, wk = pcall(require, "which-key") | ||
if not status_ok then | ||
return | ||
end | ||
local wk = require("which-key") | ||
|
||
local mappings = { | ||
{ "<leader>N", "<cmd> enew <CR>", desc = "New Buffer", nowait = true, remap = false }, | ||
{ "<leader>c", "<cmd> BufferClose <CR>", desc = "Close Buffer", nowait = true, remap = false }, | ||
{ "<leader>e", "<cmd> NvimTreeToggle<CR>", desc = "Nvim Tree Toggle", nowait = true, remap = false }, | ||
{ "<leader>q", "<cmd> q! <CR>", desc = "Quit", nowait = true, remap = false }, | ||
{ "<leader>w", "<cmd> w! <CR><CR>", desc = "Save", nowait = true, remap = false }, | ||
{ "<leader>f", "<cmd> Telescope find_files <CR>", desc = "Find Files", nowait = true, remap = false }, | ||
{ "<leader>p", "<cmd> Telescope projects <CR>", desc = "Projects", nowait = true, remap = false }, | ||
["e"] = { "<cmd> NvimTreeToggle <CR>", "Nvim Tree Toggle" }, | ||
["N"] = { "<cmd> enew <CR>", "New buffer" }, | ||
["w"] = { "<cmd> w! <CR><CR>", "Save" }, | ||
["q"] = { "<cmd> q! <CR>", "Quit" }, | ||
["c"] = { "<cmd> BufferClose <CR>", "Close Buffer" }, | ||
["f"] = { "<cmd> Telescope find_files <CR>", "Find files" }, | ||
["p"] = { "<cmd> Telescope projects <CR>", "Projects" }, | ||
|
||
-- Diagnostics | ||
{ "<leader>d", group = "Diagnostics", nowait = true, remap = false }, | ||
{ "<leader>db", "<cmd> Telescope diagnostics bufnr=0 <CR>", desc = "Buffer Diagnostics", nowait = true, remap = false }, | ||
{ "<leader>dp", "<cmd> Telescope diagnostics <CR>", desc = "Workspace Diagnostics", nowait = true, remap = false }, | ||
|
||
-- Finding files/texts etc | ||
{ "<leader>F", group = "Find", nowait = true, remap = false }, | ||
{ "<leader>Fa", "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", desc = "Find All", nowait = true, remap = false }, | ||
{ "<leader>Fl", "<cmd> Telescope live_grep <CR>", desc = "Find Text", nowait = true, remap = false }, | ||
{ "<leader>Fb", "<cmd> Telescope buffers <CR>", desc = "Find Buffers", nowait = true, remap = false }, | ||
{ "<leader>Fh", "<cmd> Telescope help_tags <CR>", desc = "Help Page", nowait = true, remap = false }, | ||
{ "<leader>Fo", "<cmd> Telescope oldfiles <CR>", desc = "Find Old Files", nowait = true, remap = false }, | ||
{ "<leader>Fk", "<cmd> Telescope filetypes <CR>", desc = "Find Types", nowait = true, remap = false }, | ||
{ "<leader>Fc", "<cmd> Telescope current_buffer_fuzzy_find <CR>", desc = "Find in Current Buffer", nowait = true, remap = false }, | ||
-- Diagnostics | ||
d = { | ||
name = "Diagnostics", | ||
b = { "<cmd> Telescope diagnostics bufnr=0 <CR>", "Buffer Diagnostics" }, | ||
p = { "<cmd> Telescope diagnostics <CR>", "Workspace Diagnostics" }, | ||
}, | ||
|
||
-- Git | ||
{ "<leader>g", group = "Git", nowait = true, remap = false }, | ||
{ "<leader>gb", "<cmd> Telescope git_branches <CR>", desc = "Git branches", nowait = true, remap = false }, | ||
{ "<leader>gc", "<cmd> Telescope git_commits <CR>", desc = "Git commit", nowait = true, remap = false }, | ||
{ "<leader>gf", "<cmd> Telescope git_files <CR>", desc = "Git files", nowait = true, remap = false }, | ||
{ "<leader>gh", "<cmd> Telescope git_stash <CR>", desc = "Git stash", nowait = true, remap = false }, | ||
{ "<leader>gs", "<cmd> Telescope git_status <CR>", desc = "Git Status", nowait = true, remap = false }, | ||
-- finding files/text etc | ||
F = { | ||
name = "Find", | ||
a = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find All" }, | ||
l = { "<cmd> Telescope live_grep <CR>", "Find Text" }, | ||
b = { "<cmd> Telescope buffers <CR>", "Find Buffers" }, | ||
h = { "<cmd> Telescope help_tags <CR>", "Help Page" }, | ||
o = { "<cmd> Telescope oldfiles <CR>", "Find Old Files" }, | ||
k = { "<cmd> Telescope filetypes <CR>", "File Types" }, | ||
c = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in Current Buffer" }, | ||
}, | ||
|
||
|
||
-- Git | ||
g = { | ||
name = "Git", | ||
s = { "<cmd> Telescope git_status <CR>", "Git Status" }, | ||
b = { "<cmd> Telescope git_branches <CR>", "Git branches" }, | ||
c = { "<cmd> Telescope git_commits <CR>", "Git commit" }, | ||
f = { "<cmd> Telescope git_files <CR>", "Git files" }, | ||
h = { "<cmd> Telescope git_stash <CR>", "Git stash" }, | ||
}, | ||
|
||
-- Buffer management using Barbar plugin | ||
{ "<leader>B", group = "Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bc", "<cmd> BufferCloseAllButCurrentOrPinned <CR>", desc = "Delete Picked Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bd", "<cmd> BufferPickDelete <CR>", desc = "Delete Picked Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bf", "<cmd> BufferFirst <CR>", desc = "Move to First Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bi", "<cmd> BufferPick <CR>", desc = "Buffer Pick", nowait = true, remap = false }, | ||
{ "<leader>Bl", "<cmd> BufferLast <CR>", desc = "Move to Last Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bp", "<cmd> BufferPin <CR>", desc = "Pin/Unpin Buffer", nowait = true, remap = false }, | ||
{ "<leader>Bs", "<cmd> BufferMoveStart <CR>", desc = "Move Buffer to Start", nowait = true, remap = false }, | ||
{ "<leader>Bt", "<cmd> BufferRestore <CR>", desc = "Restore Buffer", nowait = true, remap = false }, | ||
-- Buffer Ordering | ||
{ "<leader>Bo", group = "Order", nowait = true, remap = false }, | ||
{ "<leader>Bod", "<cmd> BufferOrderByDirectory <CR>", desc = "Order by Directory", nowait = true, remap = false }, | ||
{ "<leader>Bol", "<cmd> BufferOrderByLanguage <CR>", desc = "Order by Language", nowait = true, remap = false }, | ||
{ "<leader>Bon", "<cmd> BufferOrderByBufferNumber <CR>", desc = "Order by Buffer Number", nowait = true, remap = false }, | ||
{ "<leader>Bow", "<cmd> BufferOrderByWindowNumber <CR>", desc = "Order by Window Number", nowait = true, remap = false }, | ||
B = { | ||
name = "Buffer", | ||
f = { "<cmd> BufferFirst <CR>", "Move to First Buffer" }, | ||
l = { "<cmd> BufferLast <CR>", "Move to Last Buffer" }, | ||
p = { "<cmd> BufferPin <CR>", "Pin/Unpin Buffer" }, | ||
t = { "<cmd> BufferRestore <CR>", "Restore Buffer" }, | ||
s = { "<cmd> BufferMoveStart <CR>", "Move Buffer to Start" }, | ||
i = { "<cmd> BufferPick <CR>", "Buffer Pick" }, | ||
d = { "<cmd> BufferPickDelete <CR>", "Delete Picked Buffer" }, | ||
c = { "<cmd> BufferCloseAllButCurrentOrPinned <CR>", "Delete Picked Buffer" }, | ||
o = { | ||
name = "Order", | ||
n = { "<cmd> BufferOrderByBufferNumber <CR>", "Order by Buffer Number" }, | ||
d = { "<cmd> BufferOrderByDirectory <CR>", "Order by Directory" }, | ||
l = { "<cmd> BufferOrderByLanguage <CR>", "Order by Language" }, | ||
w = { "<cmd> BufferOrderByWindowNumber <CR>", "Order by Window Number" }, | ||
}, | ||
}, | ||
|
||
-- Update/Install plugins and languages extensions | ||
{ "<leader>s", group = "Update/Install", nowait = true, remap = false }, | ||
-- For Lazy Plugin Manager | ||
{ "<leader>sl", group = "Lazy - Plugin Manager", nowait = true, remap = false }, | ||
{ "<leader>slc", "<cmd> Lazy clean <CR>", desc = "Clean", nowait = true, remap = false }, | ||
{ "<leader>sle", "<cmd> Lazy health <CR>", desc = "Health", nowait = true, remap = false }, | ||
{ "<leader>slh", "<cmd> Lazy help <CR>", desc = "Help", nowait = true, remap = false }, | ||
{ "<leader>slk", "<cmd> Lazy check <CR>", desc = "Check", nowait = true, remap = false }, | ||
{ "<leader>sll", "<cmd> Lazy log <CR>", desc = "Log", nowait = true, remap = false }, | ||
{ "<leader>slr", "<cmd> Lazy reload <CR>", desc = "Reload", nowait = true, remap = false }, | ||
{ "<leader>sls", "<cmd> Lazy sync <CR>", desc = "Sync", nowait = true, remap = false }, | ||
{ "<leader>slu", "<cmd> Lazy update <CR>", desc = "Update", nowait = true, remap = false }, | ||
s = { | ||
name = "Update/Install", | ||
l = { | ||
name = "Lazy - Plugin Manager", | ||
s = { "<cmd> Lazy sync <CR>", "Sync" }, | ||
k = { "<cmd> Lazy check <CR>", "Check" }, | ||
h = { "<cmd> Lazy help <CR>", "Help" }, | ||
c = { "<cmd> Lazy clean <CR>", "Clean" }, | ||
e = { "<cmd> Lazy health <CR>", "Health" }, | ||
l = { "<cmd> Lazy log <CR>", "Log" }, | ||
u = { "<cmd> Lazy update <CR>", "Update" }, | ||
r = { "<cmd> Lazy reload <CR>", "Reload" }, | ||
}, | ||
}, | ||
|
||
-- Setup Related Keymappings | ||
z = { | ||
name = "Setup Keys", | ||
t = { "<cmd> Telescope colorscheme <CR>", "Colorschemes" }, | ||
h = { "<cmd> checkhealth <CR>", "Checkhealth" }, | ||
}, | ||
} | ||
|
||
-- Setup Releated Keymappings | ||
{ "<leader>z", group = "Setup Keys", nowait = true, remap = false }, | ||
{ "<leader>zt", "<cmd> Telescope colorscheme <CR>", desc = "Coloschemes", nowait = true, remap = false }, | ||
{ "<leader>zh", "<cmd> checkhealth <CR>", desc = "Checkhealth", nowait = true, remap = false }, | ||
-- Configuring Which-Key | ||
local setup = { | ||
plugins = { | ||
marks = true, -- shows a list of your marks on ' and ` | ||
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode | ||
spelling = { | ||
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions | ||
suggestions = 20, -- how many suggestions should be shown in the list? | ||
}, | ||
-- the presets plugin, adds help for a bunch of default keybindings in Neovim | ||
-- No actual key bindings are created | ||
presets = { | ||
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion | ||
motions = true, -- adds help for motions | ||
text_objects = true, -- help for text objects triggered after entering an operator | ||
windows = true, -- default bindings on <c-w> | ||
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: | ||
-- ["<space>"] = "SPC", | ||
-- ["<cr>"] = "RET", | ||
-- ["<tab>"] = "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 = "<c-d>", -- binding to scroll down inside the popup | ||
scroll_up = "<c-u>", -- binding to scroll up inside the popup | ||
}, | ||
window = { | ||
border = "rounded", -- 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 = false, -- enable this to hide mappings for which you didn't specify a label | ||
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 | ||
triggers = "auto", -- automatically setup triggers | ||
-- 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" }, | ||
}, | ||
} | ||
|
||
wk.add(mappings) | ||
-- Setting for all the keys | ||
local opts = { | ||
mode = "n", -- NORMAL mode | ||
prefix = "<leader>", | ||
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 | ||
} | ||
|
||
wk.setup(setup) | ||
wk.register(mappings, opts) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters