From 85a34ff49ffd56ab43a710cf0fe9ff6ea30fd8e6 Mon Sep 17 00:00:00 2001 From: jabuxas Date: Thu, 5 Sep 2024 10:15:52 -0300 Subject: [PATCH] fix: lsp keys not working --- init.lua | 31 +------------------------------ lua/jabuxas/remap.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/init.lua b/init.lua index 0105700..fd0a2ad 100644 --- a/init.lua +++ b/init.lua @@ -312,36 +312,6 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end - - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.lsp.buf.format() @@ -360,6 +330,7 @@ local on_attach = function(_, bufnr) vim.diagnostic.config({ float = { border = "single" } }) end local servers = { + ocamllsp = {}, gopls = { gopls = { usePlaceholders = true, diff --git a/lua/jabuxas/remap.lua b/lua/jabuxas/remap.lua index 274cf8b..483c00d 100644 --- a/lua/jabuxas/remap.lua +++ b/lua/jabuxas/remap.lua @@ -60,3 +60,34 @@ keymap.set("n", "tA", "GoTestAdd", { desc = "Add Go Test for cu keymap.set("n", "gr", "lua vim.lsp.buf.rename()", { desc = "Renames all references to the symbol under the cursor" }) + +local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) +end + + +nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') +nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + +nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') +nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') +nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') +nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') +nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') +nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + +-- See `:help K` for why this keymap +nmap('K', vim.lsp.buf.hover, 'Hover Documentation') +nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + +-- Lesser used LSP functionality +nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') +nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') +nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') +nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +end, '[W]orkspace [L]ist Folders')