using the new format for which-key

This commit is contained in:
aminnairi
2025-01-05 10:16:05 +01:00
parent b6c93a5c87
commit fa59d07e87
3 changed files with 26 additions and 144 deletions
@@ -13,27 +13,10 @@ return {
local whichKey = require("which-key") local whichKey = require("which-key")
whichKey.register({ whichKey.register({
"<leader>b", { "", "<leader>bcl", desc = "<cmd>BufferCloseAllBuffersLeft<cr>" },
desc = "Barbar", { "", desc = "<leader>bc" },
{ { "", "<leader>bcr", desc = "<cmd>BufferCloseAllBuffersRight<cr>" },
"<leader>bc", { "", "<leader>bcc", desc = "<cmd>BufferCloseAllButCurrent<cr>" },
desc = "Barbar Close",
{
"<leader>bcc",
"<cmd>BufferCloseAllButCurrent<cr>",
desc = "Barbar Close All But Current"
},
{
"<leader>bcl",
"<cmd>BufferCloseAllBuffersLeft<cr>",
desc = "Barbar Close All Buffers Left"
},
{
"<leader>bcr",
"<cmd>BufferCloseAllBuffersRight<cr>",
desc = "Barbar Close All Buffers Right"
}
},
}) })
map("n", "<A-,>", "<Cmd>BufferPrevious<CR>", opts) map("n", "<A-,>", "<Cmd>BufferPrevious<CR>", opts)
@@ -19,105 +19,22 @@ return {
local on_attach = function(_, buffer) local on_attach = function(_, buffer)
whichKey.register({ whichKey.register({
["<leader>l"] = { { "<leader>l", group = "LSP" },
name = "LSP", { "<leader>lb", group = "LSP Buffer" },
d = { { "<leader>lbD", function() vim.lsp.buf.declaration() end, buffer = 1, desc = "Go to symbol declaration" },
name = "LSP Diagnostic", { "<leader>lbR", function() vim.lsp.buf.references() end, buffer = 1, desc = "Go to symbol references" },
o = { { "<leader>lbc", function() vim.lsp.buf.code_action() end, buffer = 1, desc = "LSP code action" },
function() { "<leader>lbd", function() vim.lsp.buf.definition() end, buffer = 1, desc = "Go to symbol definition" },
vim.diagnostic.open_float() { "<leader>lbf", function() vim.lsp.buf.format() end, buffer = 1, desc = "Format file" },
end, { "<leader>lbh", function() vim.lsp.buf.hover() end, buffer = 1, desc = "Hover symbol documentation" },
"Open LSP diagnostic", { "<leader>lbi", function() vim.lsp.buf.implementation() end, buffer = 1, desc = "Go to symbol implementation" },
}, { "<leader>lbr", function() vim.lsp.buf.rename() end, buffer = 1, desc = "Rename symbol" },
p = { { "<leader>lbs", function() vim.lsp.buf.signature_help() end, buffer = 1, desc = "Go to symbol signature" },
function() { "<leader>lbt", function() vim.lsp.buf.type_definition() end, buffer = 1, desc = "Go to symbol type definition" },
vim.diagnostic.goto_prev() { "<leader>ld", group = "LSP Diagnostic" },
end, { "<leader>ldn", function() vim.diagnostic.goto_next() end, desc = "Next LSP diagnostic" },
"Previous LSP diagnostic", { "<leader>ldo", function() vim.diagnostic.open_float() end, desc = "Open LSP diagnostic" },
}, { "<leader>ldp", function() vim.diagnostic.goto_prev() end, desc = "Previous LSP diagnostic" },
n = {
function()
vim.diagnostic.goto_next()
end,
"Next LSP diagnostic",
},
},
b = {
name = "LSP Buffer",
D = {
function()
vim.lsp.buf.declaration()
end,
"Go to symbol declaration",
buffer = buffer,
},
d = {
function()
vim.lsp.buf.definition()
end,
"Go to symbol definition",
buffer = buffer,
},
h = {
function()
vim.lsp.buf.hover()
end,
"Hover symbol documentation",
buffer = buffer,
},
i = {
function()
vim.lsp.buf.implementation()
end,
"Go to symbol implementation",
buffer = buffer,
},
s = {
function()
vim.lsp.buf.signature_help()
end,
"Go to symbol signature",
buffer = buffer,
},
t = {
function()
vim.lsp.buf.type_definition()
end,
"Go to symbol type definition",
buffer = buffer,
},
r = {
function()
vim.lsp.buf.rename()
end,
"Rename symbol",
buffer = buffer,
},
c = {
function()
vim.lsp.buf.code_action()
end,
"LSP code action",
buffer = buffer,
},
R = {
function()
vim.lsp.buf.references()
end,
"Go to symbol deferences",
buffer = buffer,
},
f = {
function()
vim.lsp.buf.format({
async = true,
})
end,
"Format file",
buffer = buffer,
},
},
},
}) })
end end
@@ -7,30 +7,12 @@ return {
end, end,
config = function() config = function()
require("which-key").register({ require("which-key").register({
["<C-s>"] = { { "<C-h>", "<C-w>h", desc = "Move to the window on the left" },
":write<CR>", { "<C-j>", "<C-w>j", desc = "Move to the window on the bottom" },
"Persist the content of the current buffer to the file system" { "<C-k>", "<C-w>k", desc = "Move to the window on the top" },
}, { "<C-l>", "<C-w>l", desc = "Move to the window on the right" },
["<C-q>"] = { { "<C-q>", ":quitall<CR>", desc = "Quit the editor with confirmation" },
":quitall<CR>", { "<C-s>", ":write<CR>", desc = "Persist the content of the current buffer to the file system" },
"Quit the editor with confirmation"
},
["<C-h>"] = {
"<C-w>h",
"Move to the window on the left"
},
["<C-l>"] = {
"<C-w>l",
"Move to the window on the right"
},
["<C-k>"] = {
"<C-w>k",
"Move to the window on the top"
},
["<C-j>"] = {
"<C-w>j",
"Move to the window on the bottom"
}
}) })
end end
} }