From cfa702e6fe2f875a2c674182fe2f86e8f613aa1e Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 3 May 2022 01:10:51 +0200 Subject: refactor: use api-autocmds for lsp functions (#2549) * refactor: use api-autocmds for lsp functions * chore: use the existing client.supports_method api * fix: a callback in an autocmd doesn't pass nil * revert: keep changes minimal to which-key Co-authored-by: Abouzar Parvan --- lua/lvim/lsp/config.lua | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'lua/lvim/lsp/config.lua') diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index eada4ce7..a0e22107 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -94,15 +94,24 @@ return { }, buffer_mappings = { normal_mode = { - ["K"] = { "lua vim.lsp.buf.hover()", "Show hover" }, - ["gd"] = { "lua vim.lsp.buf.definition()", "Goto Definition" }, - ["gD"] = { "lua vim.lsp.buf.declaration()", "Goto declaration" }, - ["gr"] = { "lua vim.lsp.buf.references()", "Goto references" }, - ["gI"] = { "lua vim.lsp.buf.implementation()", "Goto Implementation" }, - ["gs"] = { "lua vim.lsp.buf.signature_help()", "show signature help" }, - ["gp"] = { "lua require'lvim.lsp.peek'.Peek('definition')", "Peek definition" }, + ["K"] = { vim.lsp.buf.hover, "Show hover" }, + ["gd"] = { vim.lsp.buf.definition, "Goto Definition" }, + ["gD"] = { vim.lsp.buf.declaration, "Goto declaration" }, + ["gr"] = { vim.lsp.buf.references, "Goto references" }, + ["gI"] = { vim.lsp.buf.implementation, "Goto Implementation" }, + ["gs"] = { vim.lsp.buf.signature_help, "show signature help" }, + ["gp"] = { + function() + require("lvim.lsp.peek").Peek "definition" + end, + "Peek definition", + }, ["gl"] = { - "lua require'lvim.lsp.handlers'.show_line_diagnostics()", + function() + local config = lvim.lsp.diagnostics.float + config.scope = "line" + vim.diagnostic.open_float(0, config) + end, "Show line diagnostics", }, }, -- cgit v1.2.3