home: vim: update for 'which-key' v3

It complains quite loudly about the legacy mapping syntax.
This commit is contained in:
Bruno BELANYI 2024-07-20 22:43:19 +01:00
parent 4de7886950
commit 58760280be
7 changed files with 208 additions and 193 deletions

View file

@ -1,7 +1,7 @@
local wk = require("which-key") local wk = require("which-key")
local keys = { local keys = {
["<leader>"] = { "<cmd>nohls<CR>", "Clear search highlight" }, { "<leader><leader>", "<cmd>nohls<CR>", desc = "Clear search highlight" },
} }
wk.register(keys, { prefix = "<leader>" }) wk.add(keys)

View file

@ -3,126 +3,124 @@ local wk = require("which-key")
local lsp = require("ambroisie.lsp") local lsp = require("ambroisie.lsp")
local keys = { local keys = {
-- Edition and navigation mappins -- Previous
["["] = { { "[", group = "Previous" },
name = "Previous", -- Edition and navigation mappings
["<space>"] = "Insert blank line above", { "[<space>", desc = "Insert blank line above" },
["<C-L>"] = "Previous location list file", { "[<C-L>", desc = "Previous location list file" },
["<C-Q>"] = "Previous quickfix list file", { "[<C-Q>", desc = "Previous quickfix list file" },
["<C-T>"] = "Previous tag in preview window", { "[<C-T>", desc = "Previous tag in preview window" },
a = "Previous argument", { "[a", desc = "Previous argument" },
A = "First argument", { "[A", desc = "First argument" },
b = "Previous buffer", { "[b", desc = "Previous buffer" },
B = "First buffer", { "[B", desc = "First buffer" },
e = "Exchange previous line", { "[e", desc = "Exchange previous line" },
f = "Previous file in directory", { "[f", desc = "Previous file in directory" },
l = "Previous location list entry", { "[l", desc = "Previous location list entry" },
L = "First Location list entry", { "[L", desc = "First Location list entry" },
n = "Previous conflict marker/diff hunk", { "[n", desc = "Previous conflict marker/diff hunk" },
p = "Paste line above", { "[p", desc = "Paste line above" },
P = "Paste line above", { "[P", desc = "Paste line above" },
q = "Previous quickfix list entry", { "[q", desc = "Previous quickfix list entry" },
Q = "First quickfix list entry", { "[Q", desc = "First quickfix list entry" },
t = "Previous matching tag", { "[t", desc = "Previous matching tag" },
T = "First matching tag", { "[T", desc = "First matching tag" },
z = "Previous fold", { "[z", desc = "Previous fold" },
-- Encoding -- Encoding
C = "C string encode", { "[C", desc = "C string encode" },
u = "URL encode", { "[u", desc = "URL encode" },
x = "XML encode", { "[x", desc = "XML encode" },
y = "C string encode", { "[y", desc = "C string encode" },
-- Custom -- Custom
d = { lsp.goto_prev_diagnostic, "Previous diagnostic" }, { "[d", lsp.goto_prev_diagnostic, desc = "Previous diagnostic" },
},
["]"] = {
name = "Next",
["<space>"] = "Insert blank line below",
["<C-L>"] = "Next location list file",
["<C-Q>"] = "Next quickfix list file",
["<C-T>"] = "Next tag in preview window",
a = "Next argument",
A = "Last argument",
b = "Next buffer",
B = "Last buffer",
e = "Exchange next line",
f = "Next file in directory",
l = "Next location list entry",
L = "Last Location list entry",
n = "Next conflict marker/diff hunk",
p = "Paste line below",
P = "Paste line below",
q = "Next quickfix list entry",
Q = "Last quickfix list entry",
t = "Next matching tag",
T = "Last matching tag",
z = "Next fold",
-- Decoding
C = "C string decode",
u = "URL decode",
x = "XML decode",
y = "C string decode",
-- Custom
d = { lsp.goto_next_diagnostic, "Next diagnostic" },
},
-- Option mappings -- Next
["[o"] = { { "]", group = "Next" },
name = "Enable option", -- Edition and navigation mappings
b = "Light background", { "]<space>", desc = "Insert blank line below" },
c = "Cursor line", { "]<C-L>", desc = "Next location list file" },
d = "Diff", { "]<C-Q>", desc = "Next quickfix list file" },
f = { "<cmd>FormatEnable<CR>", "LSP Formatting" }, { "]<C-T>", desc = "Next tag in preview window" },
h = "Search high-lighting", { "]a", desc = "Next argument" },
i = "Case insensitive search", { "]A", desc = "Last argument" },
l = "List mode", { "]b", desc = "Next buffer" },
n = "Line numbers", { "]B", desc = "Last buffer" },
r = "Relative line numbers", { "]e", desc = "Exchange next line" },
p = { "<cmd>lwindow<CR>", "Location list" }, { "]f", desc = "Next file in directory" },
q = { "<cmd>cwindow<CR>", "Quickfix list" }, { "]l", desc = "Next location list entry" },
u = "Cursor column", { "]L", desc = "Last Location list entry" },
v = "Virtual editing", { "]n", desc = "Next conflict marker/diff hunk" },
w = "Text wrapping", { "]p", desc = "Paste line below" },
x = "Cursor line and column", { "]P", desc = "Paste line below" },
z = "Spell checking", { "]q", desc = "Next quickfix list entry" },
}, { "]Q", desc = "Last quickfix list entry" },
["]o"] = { { "]t", desc = "Next matching tag" },
name = "Disable option", { "]T", desc = "Last matching tag" },
b = "Light background", { "]z", desc = "Next fold" },
c = "Cursor line", -- Decoding
d = "Diff", { "]C", desc = "C string decode" },
f = { "<cmd>FormatDisable<CR>", "LSP Formatting" }, { "]u", desc = "URL decode" },
h = "Search high-lighting", { "]x", desc = "XML decode" },
i = "Case insensitive search", { "]y", desc = "C string decode" },
l = "List mode", -- Custom
n = "Line numbers", { "]d", lsp.goto_next_diagnostic, desc = "Next diagnostic" },
p = { "<cmd>lclose<CR>", "Location list" },
q = { "<cmd>cclose<CR>", "Quickfix list" }, -- Enable option
r = "Relative line numbers", { "[o", desc = "Enable option" },
u = "Cursor column", { "[ob", desc = "Light background" },
v = "Virtual editing", { "[oc", desc = "Cursor line" },
w = "Text wrapping", { "[od", desc = "Diff" },
x = "Cursor line and column", { "[of", "<cmd>FormatEnable<CR>", desc = "LSP Formatting" },
z = "Spell checking", { "[oh", desc = "Search high-lighting" },
}, { "[oi", desc = "Case insensitive search" },
["yo"] = { { "[ol", desc = "List mode" },
name = "Toggle option", { "[on", desc = "Line numbers" },
b = "Light background", { "[or", desc = "Relative line numbers" },
c = "Cursor line", { "[op", "<cmd>lwindow<CR>", desc = "Location list" },
d = "Diff", { "[oq", "<cmd>cwindow<CR>", desc = "Quickfix list" },
f = { "<cmd>FormatToggle<CR>", "LSP Formatting" }, { "[ou", desc = "Cursor column" },
h = "Search high-lighting", { "[ov", desc = "Virtual editing" },
i = "Case insensitive search", { "[ow", desc = "Text wrapping" },
l = "List mode", { "[ox", desc = "Cursor line and column" },
n = "Line numbers", { "[oz", desc = "Spell checking" },
p = { "<Plug>(qf_loc_toggle)", "Location list" },
q = { "<Plug>(qf_qf_toggle)", "Quickfix list" }, -- Disable option
r = "Relative line numbers", { "]o", desc = "Disable option" },
u = "Cursor column", { "]ob", desc = "Light background" },
v = "Virtual editing", { "]oc", desc = "Cursor line" },
w = "Text wrapping", { "]od", desc = "Diff" },
x = "Cursor line and column", { "]of", "<cmd>FormatDisable<CR>", desc = "LSP Formatting" },
z = "Spell checking", { "]oh", desc = "Search high-lighting" },
}, { "]oi", desc = "Case insensitive search" },
{ "]ol", desc = "List mode" },
{ "]on", desc = "Line numbers" },
{ "]op", "<cmd>lclose<CR>", desc = "Location list" },
{ "]oq", "<cmd>cclose<CR>", desc = "Quickfix list" },
{ "]or", desc = "Relative line numbers" },
{ "]ou", desc = "Cursor column" },
{ "]ov", desc = "Virtual editing" },
{ "]ow", desc = "Text wrapping" },
{ "]ox", desc = "Cursor line and column" },
{ "]oz", desc = "Spell checking" },
-- Toggle option
{ "yo", group = "Toggle option" },
{ "yob", desc = "Light background" },
{ "yoc", desc = "Cursor line" },
{ "yod", desc = "Diff" },
{ "yof", "<cmd>FormatToggle<CR>", desc = "LSP Formatting" },
{ "yoh", desc = "Search high-lighting" },
{ "yoi", desc = "Case insensitive search" },
{ "yol", desc = "List mode" },
{ "yon", desc = "Line numbers" },
{ "yop", "<Plug>(qf_loc_toggle)", desc = "Location list" },
{ "yoq", "<Plug>(qf_qf_toggle)", desc = "Quickfix list" },
{ "yor", desc = "Relative line numbers" },
{ "you", desc = "Cursor column" },
{ "yov", desc = "Virtual editing" },
{ "yow", desc = "Text wrapping" },
{ "yox", desc = "Cursor line and column" },
{ "yoz", desc = "Spell checking" },
} }
wk.register(keys) wk.add(keys)

View file

@ -87,31 +87,30 @@ M.on_attach = function(client, bufnr)
end end
local keys = { local keys = {
K = { vim.lsp.buf.hover, "Show symbol information" }, buffer = bufnr,
["<C-k>"] = { vim.lsp.buf.signature_help, "Show signature information" }, -- LSP navigation
["gd"] = { vim.lsp.buf.definition, "Go to definition" }, { "K", vim.lsp.buf.hover, desc = "Show symbol information" },
["gD"] = { vim.lsp.buf.declaration, "Go to declaration" }, { "<C-k>", vim.lsp.buf.signature_help, desc = "Show signature information" },
["gi"] = { vim.lsp.buf.implementation, "Go to implementation" }, { "gd", vim.lsp.buf.definition, desc = "Go to definition" },
["gr"] = { vim.lsp.buf.references, "List all references" }, { "gD", vim.lsp.buf.declaration, desc = "Go to declaration" },
{ "gi", vim.lsp.buf.implementation, desc = "Go to implementation" },
["<leader>c"] = { { "gr", vim.lsp.buf.references, desc = "List all references" },
name = "Code", -- Code
a = { vim.lsp.buf.code_action, "Code actions" }, { "<leader>c", group = "Code" },
d = { cycle_diagnostics_display, "Cycle diagnostics display" }, { "<leader>ca", vim.lsp.buf.code_action, desc = "Code actions" },
D = { show_buffer_diagnostics, "Show buffer diagnostics" }, { "<leader>cd", cycle_diagnostics_display, desc = "Cycle diagnostics display" },
r = { vim.lsp.buf.rename, "Rename symbol" }, { "<leader>cD", show_buffer_diagnostics, desc = "Show buffer diagnostics" },
s = { vim.lsp.buf.signature_help, "Show signature" }, { "<leader>cr", vim.lsp.buf.rename, desc = "Rename symbol" },
t = { vim.lsp.buf.type_definition, "Go to type definition" }, { "<leader>cs", vim.lsp.buf.signature_help, desc = "Show signature" },
w = { { "<leader>ct", vim.lsp.buf.type_definition, desc = "Go to type definition" },
name = "Workspace", -- Workspace
a = { vim.lsp.buf.add_workspace_folder, "Add folder to workspace" }, { "<leader>cw", group = "Workspace" },
l = { list_workspace_folders, "List folders in workspace" }, { "<leader>cwa", vim.lsp.buf.add_workspace_folder, desc = "Add folder to workspace" },
r = { vim.lsp.buf.remove_workspace_folder, "Remove folder from workspace" }, { "<leader>cwl", list_workspace_folders, desc = "List folders in workspace" },
}, { "<leader>cwr", vim.lsp.buf.remove_workspace_folder, desc = "Remove folder from workspace" },
},
} }
wk.register(keys, { buffer = bufnr }) wk.add(keys)
end end
return M return M

View file

@ -34,47 +34,42 @@ gitsigns.setup({
local keys = { local keys = {
-- Navigation -- Navigation
["[c"] = { utils.partial(nav_hunk, "prev"), "Previous hunk/diff" }, { "[c", utils.partial(nav_hunk, "prev"), desc = "Previous hunk/diff" },
["]c"] = { utils.partial(nav_hunk, "next"), "Next hunk/diff" }, { "]c", utils.partial(nav_hunk, "next"), desc = "Next hunk/diff" },
-- Commands -- Commands
["<leader>g"] = { { "<leader>g", group = "Git" },
name = "Git", { "<leader>gb", gitsigns.toggle_current_line_blame, desc = "Toggle blame virtual text" },
-- Actions { "<leader>gd", gitsigns.diffthis, desc = "Diff buffer" },
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" }, { "<leader>gD", utils.partial(gitsigns.diffthis, "~"), desc = "Diff buffer against last commit" },
d = { gitsigns.diffthis, "Diff buffer" }, { "<leader>gg", "<cmd>Git<CR>", desc = "Git status" },
D = { utils.partial(gitsigns.diffthis, "~"), "Diff buffer against last commit" }, { "<leader>gh", gitsigns.toggle_deleted, desc = "Show deleted hunks" },
g = { "<cmd>Git<CR>", "Git status" }, { "<leader>gL", "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", desc = "Current buffer log" },
h = { gitsigns.toggle_deleted, "Show deleted hunks" }, { "<leader>gm", "<Plug>(git-messenger)", desc = "Current line blame" },
L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" }, { "<leader>gp", gitsigns.preview_hunk, desc = "Preview hunk" },
m = { "<Plug>(git-messenger)", "Current line blame" }, { "<leader>gr", gitsigns.reset_hunk, desc = "Restore hunk" },
p = { gitsigns.preview_hunk, "Preview hunk" }, { "<leader>gR", gitsigns.reset_buffer, desc = "Restore buffer" },
r = { gitsigns.reset_hunk, "Restore hunk" }, { "<leader>gs", gitsigns.stage_hunk, desc = "Stage hunk" },
R = { gitsigns.reset_buffer, "Restore buffer" }, { "<leader>gS", gitsigns.stage_buffer, desc = "Stage buffer" },
s = { gitsigns.stage_hunk, "Stage hunk" }, { "<leader>gu", gitsigns.undo_stage_hunk, desc = "Undo stage hunk" },
S = { gitsigns.stage_buffer, "Stage buffer" }, { "<leader>g[", utils.partial(gitsigns.nav_hunk, "prev"), desc = "Previous hunk" },
u = { gitsigns.undo_stage_hunk, "Undo stage hunk" }, { "<leader>g]", utils.partial(gitsigns.nav_hunk, "next"), desc = "Next hunk" },
["["] = { utils.partial(gitsigns.nav_hunk, "prev"), "Previous hunk" },
["]"] = { utils.partial(gitsigns.nav_hunk, "next"), "Next hunk" },
},
} }
local objects = { local objects = {
["ih"] = { gitsigns.select_hunk, "Git hunk" }, mode = "o",
{ "ih", gitsigns.select_hunk, desc = "Git hunk" },
} }
-- Visual
local visual = { local visual = {
["ih"] = { gitsigns.select_hunk, "Git hunk" }, mode = { "x" },
{ "ih", gitsigns.select_hunk, desc = "Git hunk" },
["<leader>g"] = { { "<leader>g", group = "Git" },
name = "Git", { "<leader>gp", gitsigns.preview_hunk, desc = "Preview selection" },
p = { gitsigns.preview_hunk, "Preview selection" }, { "<leader>gr", make_visual(gitsigns.reset_hunk), desc = "Restore selection" },
r = { make_visual(gitsigns.reset_hunk), "Restore selection" }, { "<leader>gs", make_visual(gitsigns.stage_hunk), desc = "Stage selection" },
s = { make_visual(gitsigns.stage_hunk), "Stage selection" }, { "<leader>gu", gitsigns.undo_stage_hunk, desc = "Undo stage selection" },
u = { gitsigns.undo_stage_hunk, "Undo stage selection" },
},
} }
wk.register(keys, { buffer = bufnr }) wk.add(keys)
wk.register(objects, { buffer = bufnr, mode = "o" }) wk.add(objects)
wk.register(visual, { buffer = bufnr, mode = "x" }) wk.add(visual)

View file

@ -28,7 +28,7 @@ oil.setup({
}) })
local keys = { local keys = {
["-"] = { oil.open, "Open parent directory" }, { "-", oil.open, desc = "Open parent directory" },
} }
wk.register(keys) wk.add(keys)

View file

@ -26,14 +26,12 @@ telescope.load_extension("fzf")
telescope.load_extension("lsp_handlers") telescope.load_extension("lsp_handlers")
local keys = { local keys = {
f = { { "<leader>f", group = "Fuzzy finder" },
name = "Fuzzy finder", { "<leader>fb", telescope_builtin.buffers, desc = "Open buffers" },
b = { telescope_builtin.buffers, "Open buffers" }, { "<leader>ff", telescope_builtin.git_files, desc = "Git tracked files" },
f = { telescope_builtin.git_files, "Git tracked files" }, { "<leader>fF", telescope_builtin.find_files, desc = "Files" },
F = { telescope_builtin.find_files, "Files" }, { "<leader>fg", telescope_builtin.live_grep, desc = "Grep string" },
g = { telescope_builtin.live_grep, "Grep string" }, { "<leader>fG", telescope_builtin.grep_string, desc = "Grep string under cursor" },
G = { telescope_builtin.grep_string, "Grep string under cursor" },
},
} }
wk.register(keys, { prefix = "<leader>" }) wk.add(keys)

View file

@ -1,2 +1,27 @@
local wk = require("which-key") local wk = require("which-key")
wk.setup() wk.setup({
icons = {
-- I don't like icons
mappings = false,
breadcrumb = "»",
separator = "",
group = "+",
ellipsis = "",
keys = {
Up = "",
Down = "",
Left = "",
Right = "",
C = "<C>",
M = "<M>",
D = "<D>",
S = "<S>",
CR = "<CR>",
Esc = "<Esc> ",
NL = "<NL>",
BS = "<BS>",
Space = "<space>",
Tab = "<Tab> ",
},
},
})