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 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 keys = {
-- Edition and navigation mappins
["["] = {
name = "Previous",
["<space>"] = "Insert blank line above",
["<C-L>"] = "Previous location list file",
["<C-Q>"] = "Previous quickfix list file",
["<C-T>"] = "Previous tag in preview window",
a = "Previous argument",
A = "First argument",
b = "Previous buffer",
B = "First buffer",
e = "Exchange previous line",
f = "Previous file in directory",
l = "Previous location list entry",
L = "First Location list entry",
n = "Previous conflict marker/diff hunk",
p = "Paste line above",
P = "Paste line above",
q = "Previous quickfix list entry",
Q = "First quickfix list entry",
t = "Previous matching tag",
T = "First matching tag",
z = "Previous fold",
-- Encoding
C = "C string encode",
u = "URL encode",
x = "XML encode",
y = "C string encode",
-- Custom
d = { lsp.goto_prev_diagnostic, "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" },
},
-- Previous
{ "[", group = "Previous" },
-- Edition and navigation mappings
{ "[<space>", desc = "Insert blank line above" },
{ "[<C-L>", desc = "Previous location list file" },
{ "[<C-Q>", desc = "Previous quickfix list file" },
{ "[<C-T>", desc = "Previous tag in preview window" },
{ "[a", desc = "Previous argument" },
{ "[A", desc = "First argument" },
{ "[b", desc = "Previous buffer" },
{ "[B", desc = "First buffer" },
{ "[e", desc = "Exchange previous line" },
{ "[f", desc = "Previous file in directory" },
{ "[l", desc = "Previous location list entry" },
{ "[L", desc = "First Location list entry" },
{ "[n", desc = "Previous conflict marker/diff hunk" },
{ "[p", desc = "Paste line above" },
{ "[P", desc = "Paste line above" },
{ "[q", desc = "Previous quickfix list entry" },
{ "[Q", desc = "First quickfix list entry" },
{ "[t", desc = "Previous matching tag" },
{ "[T", desc = "First matching tag" },
{ "[z", desc = "Previous fold" },
-- Encoding
{ "[C", desc = "C string encode" },
{ "[u", desc = "URL encode" },
{ "[x", desc = "XML encode" },
{ "[y", desc = "C string encode" },
-- Custom
{ "[d", lsp.goto_prev_diagnostic, desc = "Previous diagnostic" },
-- Option mappings
["[o"] = {
name = "Enable option",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatEnable<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
r = "Relative line numbers",
p = { "<cmd>lwindow<CR>", "Location list" },
q = { "<cmd>cwindow<CR>", "Quickfix list" },
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
["]o"] = {
name = "Disable option",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatDisable<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
p = { "<cmd>lclose<CR>", "Location list" },
q = { "<cmd>cclose<CR>", "Quickfix list" },
r = "Relative line numbers",
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
["yo"] = {
name = "Toggle option",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatToggle<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
p = { "<Plug>(qf_loc_toggle)", "Location list" },
q = { "<Plug>(qf_qf_toggle)", "Quickfix list" },
r = "Relative line numbers",
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
-- Next
{ "]", group = "Next" },
-- Edition and navigation mappings
{ "]<space>", desc = "Insert blank line below" },
{ "]<C-L>", desc = "Next location list file" },
{ "]<C-Q>", desc = "Next quickfix list file" },
{ "]<C-T>", desc = "Next tag in preview window" },
{ "]a", desc = "Next argument" },
{ "]A", desc = "Last argument" },
{ "]b", desc = "Next buffer" },
{ "]B", desc = "Last buffer" },
{ "]e", desc = "Exchange next line" },
{ "]f", desc = "Next file in directory" },
{ "]l", desc = "Next location list entry" },
{ "]L", desc = "Last Location list entry" },
{ "]n", desc = "Next conflict marker/diff hunk" },
{ "]p", desc = "Paste line below" },
{ "]P", desc = "Paste line below" },
{ "]q", desc = "Next quickfix list entry" },
{ "]Q", desc = "Last quickfix list entry" },
{ "]t", desc = "Next matching tag" },
{ "]T", desc = "Last matching tag" },
{ "]z", desc = "Next fold" },
-- Decoding
{ "]C", desc = "C string decode" },
{ "]u", desc = "URL decode" },
{ "]x", desc = "XML decode" },
{ "]y", desc = "C string decode" },
-- Custom
{ "]d", lsp.goto_next_diagnostic, desc = "Next diagnostic" },
-- Enable option
{ "[o", desc = "Enable option" },
{ "[ob", desc = "Light background" },
{ "[oc", desc = "Cursor line" },
{ "[od", desc = "Diff" },
{ "[of", "<cmd>FormatEnable<CR>", desc = "LSP Formatting" },
{ "[oh", desc = "Search high-lighting" },
{ "[oi", desc = "Case insensitive search" },
{ "[ol", desc = "List mode" },
{ "[on", desc = "Line numbers" },
{ "[or", desc = "Relative line numbers" },
{ "[op", "<cmd>lwindow<CR>", desc = "Location list" },
{ "[oq", "<cmd>cwindow<CR>", desc = "Quickfix list" },
{ "[ou", desc = "Cursor column" },
{ "[ov", desc = "Virtual editing" },
{ "[ow", desc = "Text wrapping" },
{ "[ox", desc = "Cursor line and column" },
{ "[oz", desc = "Spell checking" },
-- Disable option
{ "]o", desc = "Disable option" },
{ "]ob", desc = "Light background" },
{ "]oc", desc = "Cursor line" },
{ "]od", desc = "Diff" },
{ "]of", "<cmd>FormatDisable<CR>", desc = "LSP Formatting" },
{ "]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
local keys = {
K = { vim.lsp.buf.hover, "Show symbol information" },
["<C-k>"] = { vim.lsp.buf.signature_help, "Show signature information" },
["gd"] = { vim.lsp.buf.definition, "Go to definition" },
["gD"] = { vim.lsp.buf.declaration, "Go to declaration" },
["gi"] = { vim.lsp.buf.implementation, "Go to implementation" },
["gr"] = { vim.lsp.buf.references, "List all references" },
["<leader>c"] = {
name = "Code",
a = { vim.lsp.buf.code_action, "Code actions" },
d = { cycle_diagnostics_display, "Cycle diagnostics display" },
D = { show_buffer_diagnostics, "Show buffer diagnostics" },
r = { vim.lsp.buf.rename, "Rename symbol" },
s = { vim.lsp.buf.signature_help, "Show signature" },
t = { vim.lsp.buf.type_definition, "Go to type definition" },
w = {
name = "Workspace",
a = { vim.lsp.buf.add_workspace_folder, "Add folder to workspace" },
l = { list_workspace_folders, "List folders in workspace" },
r = { vim.lsp.buf.remove_workspace_folder, "Remove folder from workspace" },
},
},
buffer = bufnr,
-- LSP navigation
{ "K", vim.lsp.buf.hover, desc = "Show symbol information" },
{ "<C-k>", vim.lsp.buf.signature_help, desc = "Show signature information" },
{ "gd", vim.lsp.buf.definition, desc = "Go to definition" },
{ "gD", vim.lsp.buf.declaration, desc = "Go to declaration" },
{ "gi", vim.lsp.buf.implementation, desc = "Go to implementation" },
{ "gr", vim.lsp.buf.references, desc = "List all references" },
-- Code
{ "<leader>c", group = "Code" },
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code actions" },
{ "<leader>cd", cycle_diagnostics_display, desc = "Cycle diagnostics display" },
{ "<leader>cD", show_buffer_diagnostics, desc = "Show buffer diagnostics" },
{ "<leader>cr", vim.lsp.buf.rename, desc = "Rename symbol" },
{ "<leader>cs", vim.lsp.buf.signature_help, desc = "Show signature" },
{ "<leader>ct", vim.lsp.buf.type_definition, desc = "Go to type definition" },
-- Workspace
{ "<leader>cw", group = "Workspace" },
{ "<leader>cwa", vim.lsp.buf.add_workspace_folder, desc = "Add folder to 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
return M

View file

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

View file

@ -28,7 +28,7 @@ oil.setup({
})
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")
local keys = {
f = {
name = "Fuzzy finder",
b = { telescope_builtin.buffers, "Open buffers" },
f = { telescope_builtin.git_files, "Git tracked files" },
F = { telescope_builtin.find_files, "Files" },
g = { telescope_builtin.live_grep, "Grep string" },
G = { telescope_builtin.grep_string, "Grep string under cursor" },
},
{ "<leader>f", group = "Fuzzy finder" },
{ "<leader>fb", telescope_builtin.buffers, desc = "Open buffers" },
{ "<leader>ff", telescope_builtin.git_files, desc = "Git tracked files" },
{ "<leader>fF", telescope_builtin.find_files, desc = "Files" },
{ "<leader>fg", telescope_builtin.live_grep, desc = "Grep string" },
{ "<leader>fG", telescope_builtin.grep_string, desc = "Grep string under cursor" },
}
wk.register(keys, { prefix = "<leader>" })
wk.add(keys)

View file

@ -1,2 +1,27 @@
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> ",
},
},
})