diff --git a/nvim/plugin/autocommands.lua b/nvim/plugin/autocommands.lua index ab4d99b..ede9b77 100644 --- a/nvim/plugin/autocommands.lua +++ b/nvim/plugin/autocommands.lua @@ -76,16 +76,16 @@ vim.api.nvim_create_autocmd('LspAttach', { end -- Set name for the 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', '', vim.lsp.buf.signature_help, desc('[lsp] signature help')) - keymap.set('n', '', vim.lsp.buf.code_action, desc('[lsp] code action')) - keymap.set('n', '', 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', '', vim.lsp.buf.signature_help, { desc = '[lsp] signature help' }) + keymap.set('n', '', vim.lsp.buf.code_action, { desc = '[lsp] code action' }) + keymap.set('n', '', 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 = { "vim.lsp.codelens.refresh", '[l]sp code lenses [R]efresh' }, f = { function() vim.lsp.buf.format { async = true } end, '[l]sp [f]ormat buffer' }, }, - }, { prefix = "" }) - if client.server_capabilities.inlayHintProvider then - -- keymap.set('n', 'lh', function() - wk.register({ - ['lh'] = { function() + }, { prefix = "" }) ]] + wk.add({ + { "l", group = "[l]sp" }, + { "lR", "vim.lsp.codelens.refresh", desc = "[l]sp code lenses [R]efresh" }, + { "ld", "vim.lsp.buf.document_symbol", desc = "[l]sp [d]ocument symbol" }, + { "lf", function() vim.lsp.buf.format { async = true } end, desc = "[l]sp [f]ormat buffer" }, + { "lg", group = "[g]o to" }, + { "lgt", "vim.lsp.buf.type_definition", desc = "[l]sp [g]o to [t]ype definition" }, + { "lp", group = "[p]eek" }, + { "lpd", peek_definition, desc = "[l]sp [p]eek [d]efinition" }, + { "lpt", peek_type_definition, desc = "[l]sp [p]eek [t]ype definition" }, + { "lr", "vim.lsp.buf.rename", desc = "[l]sp [r]ename" }, + { "lw", group = "[w]orkspace" }, + { "lwa", "vim.lsp.buf.add_workspace_folder", desc = "[l]sp add [w]orksp[a]ce folder" }, + { "lwl", function() vim.print(vim.lsp.buf.list_workspace_folders()) end, desc = "[l]sp [w]orkspace folders [l]ist" }, + { "lwq", "vim.lsp.buf.workspace_symbol", desc = "[l]sp [w]orkspace symbol [q]" }, + { "lwr", "vim.lsp.buf.remove_workspace_folder", desc = "[l]sp [w]orkspace folder [r]emove" }, + }) + if client ~= nil and client.server_capabilities.inlayHintProvider then + -- keymap.set('n', 'lh', function() + wk.add({ + "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', 'lh', function()