chore: Update which-key mappings to new standard

This commit is contained in:
Jiří Štefka 2024-09-18 23:44:37 +02:00
parent dba5d1c1c1
commit c9c15d8ae1
Signed by: jiriks74
GPG Key ID: 1D5E30D3DB2264DE

@ -76,16 +76,16 @@ vim.api.nvim_create_autocmd('LspAttach', {
end
-- Set name for the <space>l prefix
keymap.set('n', 'gD', vim.lsp.buf.declaration, desc('lsp [g]o to [D]eclaration'))
keymap.set('n', 'gd', vim.lsp.buf.definition, desc('lsp [g]o to [d]efinition'))
keymap.set('n', 'K', vim.lsp.buf.hover, desc('[lsp] hover'))
keymap.set('n', 'gi', vim.lsp.buf.implementation, desc('lsp [g]o to [i]mplementation'))
keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, desc('[lsp] signature help'))
keymap.set('n', '<M-CR>', vim.lsp.buf.code_action, desc('[lsp] code action'))
keymap.set('n', '<M-l>', vim.lsp.codelens.run, desc('[lsp] run code lens'))
keymap.set('n', 'gr', vim.lsp.buf.references, desc('lsp [g]et [r]eferences'))
wk.register({
l = {
keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = 'lsp [g]o to [D]eclaration' })
keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = 'lsp [g]o to [d]efinition' })
keymap.set('n', 'K', vim.lsp.buf.hover, { desc = '[lsp] hover' })
keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = 'lsp [g]o to [i]mplementation' })
keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, { desc = '[lsp] signature help' })
keymap.set('n', '<M-CR>', vim.lsp.buf.code_action, { desc = '[lsp] code action' })
keymap.set('n', '<M-l>', vim.lsp.codelens.run, { desc = '[lsp] run code lens' })
keymap.set('n', 'gr', vim.lsp.buf.references, { desc = 'lsp [g]et [r]eferences' })
--[[ wk.register({
l = {
name = "[l]sp",
g = {
name = "[g]o to",
@ -111,15 +111,34 @@ vim.api.nvim_create_autocmd('LspAttach', {
R = { "<cmd>vim.lsp.codelens.refresh<cr>", '[l]sp code lenses [R]efresh' },
f = { function() vim.lsp.buf.format { async = true } end, '[l]sp [f]ormat buffer' },
},
}, { prefix = "<leader>" })
if client.server_capabilities.inlayHintProvider then
-- keymap.set('n', '<space>lh', function()
wk.register({
['<leader>lh'] = { function()
}, { prefix = "<leader>" }) ]]
wk.add({
{ "<leader>l", group = "[l]sp" },
{ "<leader>lR", "<cmd>vim.lsp.codelens.refresh<cr>", desc = "[l]sp code lenses [R]efresh" },
{ "<leader>ld", "<cmd>vim.lsp.buf.document_symbol<cr>", desc = "[l]sp [d]ocument symbol" },
{ "<leader>lf", function() vim.lsp.buf.format { async = true } end, desc = "[l]sp [f]ormat buffer" },
{ "<leader>lg", group = "[g]o to" },
{ "<leader>lgt", "<cmd>vim.lsp.buf.type_definition<cr>", desc = "[l]sp [g]o to [t]ype definition" },
{ "<leader>lp", group = "[p]eek" },
{ "<leader>lpd", peek_definition, desc = "[l]sp [p]eek [d]efinition" },
{ "<leader>lpt", peek_type_definition, desc = "[l]sp [p]eek [t]ype definition" },
{ "<leader>lr", "<cmd>vim.lsp.buf.rename<cr>", desc = "[l]sp [r]ename" },
{ "<leader>lw", group = "[w]orkspace" },
{ "<leader>lwa", "<cmd>vim.lsp.buf.add_workspace_folder<cr>", desc = "[l]sp add [w]orksp[a]ce folder" },
{ "<leader>lwl", function() vim.print(vim.lsp.buf.list_workspace_folders()) end, desc = "[l]sp [w]orkspace folders [l]ist" },
{ "<leader>lwq", "<cmd>vim.lsp.buf.workspace_symbol<cr>", desc = "[l]sp [w]orkspace symbol [q]" },
{ "<leader>lwr", "<cmd>vim.lsp.buf.remove_workspace_folder<cr>", desc = "[l]sp [w]orkspace folder [r]emove" },
})
if client ~= nil and client.server_capabilities.inlayHintProvider then
-- keymap.set('n', '<space>lh', function()
wk.add({
"<leader>lh",
function()
local current_setting = vim.lsp.inlay_hint.is_enabled(bufnr)
vim.lsp.inlay_hint.enable(bufnr, not current_setting)
end, '[l]sp toggle inlay [h]ints' }})
end
end, desc = '[l]sp toggle inlay [h]ints'
})
end
-- TODO: InlayHint setting not working - the code below is the original one
-- if client.server_capabilities.inlayHintProvider then
-- keymap.set('n', '<space>lh', function()