commit 455a0919c76802b351d871331181b452f5064e9d
parent 7ad205adb43ec98ace41e340cfac3ccafb0f360c
Author: Thomas Vigouroux <me@vigoux.eu>
Date: Mon, 25 Mar 2024 16:17:54 +0100
feat: add mapping descriptions
Diffstat:
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua
@@ -8,34 +8,37 @@ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' })
local function on_attach(client, bufnr)
- local function set_keymap(lhs, func)
+ local function set_keymap(lhs, func, desc)
-- vim.api.nvim_echo({ {"Setup "}, {lhs} }, true, {})
vim.keymap.set("n", lhs, "", {
remap = false,
silent = true,
buffer = bufnr,
- callback = func
+ callback = func,
+ desc = desc
})
end
local function set_autocmd(event, func)
vim.api.nvim_create_autocmd(event, {
buffer = bufnr,
- callback = function() pcall(func) end
+ callback = function() pcall(func) end,
})
end
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
if client.server_capabilities and client.server_capabilities.hoverProvider then
- set_keymap('K', vim.lsp.buf.hover)
+ set_keymap('K', vim.lsp.buf.hover, "Hover / print docs")
end
- set_keymap('<Leader>d', vim.lsp.buf.definition)
- set_keymap('gr', vim.lsp.buf.rename)
- set_keymap('<Leader>a', vim.lsp.buf.code_action)
- set_keymap('<Leader>=', vim.lsp.buf.format)
- set_keymap('gR', require "azy.builtins".lsp.references())
- set_keymap('<Leader>s', require "azy.builtins".lsp.workspace_symbols())
+ set_keymap('<Leader>d', vim.lsp.buf.definition, "Go to definition")
+ set_keymap('<Leader>gd', vim.lsp.buf.declaration, "Go to declaration")
+ set_keymap('<Leader>td', vim.lsp.buf.type_definition, "Go to type definition")
+ set_keymap('gr', vim.lsp.buf.rename, "Rename symbol at point")
+ set_keymap('<Leader>a', vim.lsp.buf.code_action, "Code action at point")
+ set_keymap('<Leader>=', vim.lsp.buf.format, "Format the whole buffer")
+ set_keymap('gR', require "azy.builtins".lsp.references(), "Search for references")
+ set_keymap('<Leader>s', require "azy.builtins".lsp.workspace_symbols(), "Search workspace symbols")
vim.opt_local.tagfunc = "v:lua.vim.lsp.tagfunc"
@@ -50,7 +53,7 @@ local function on_attach(client, bufnr)
if client.supports_method('textDocument/codeLens') then
set_autocmd({ "BufEnter", "CursorHoldI", "InsertLeave" }, vim.lsp.codelens.refresh)
- set_keymap('<Leader>lr', vim.lsp.codelens.run)
+ set_keymap('<Leader>lr', vim.lsp.codelens.run, "Run codelens")
end
-- if client.supports_method 'textDocument/inlayHint' then
@@ -233,6 +236,19 @@ local system_lsps = {
ocamllsp = {
filetypes = { "ocaml" },
+ cfg = {
+ capabilites = capabilities,
+ on_attach = on_attach,
+ settings = {
+ ocaml = {
+ server = {
+ extraEnv = {
+ OCAMLLSP_SEMANTIC_HIGHLIGHTING = "full",
+ }
+ }
+ }
+ }
+ }
},
clangd = {