From bcf24a42b737bfea720326ab84a8b601ca51c7e0 Mon Sep 17 00:00:00 2001 From: CPea Date: Fri, 3 Mar 2023 13:28:24 +0700 Subject: refactor(lsp): allow to disable custom handlers config --- lua/lvim/config/_deprecated.lua | 8 ++++++++ lua/lvim/lsp/config.lua | 10 ++++++---- lua/lvim/lsp/handlers.lua | 8 ++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'lua/lvim') diff --git a/lua/lvim/config/_deprecated.lua b/lua/lvim/config/_deprecated.lua index d4b15f30..8b06defb 100644 --- a/lua/lvim/config/_deprecated.lua +++ b/lua/lvim/config/_deprecated.lua @@ -53,6 +53,14 @@ function M.handle() lvim.lsp.popup_border = {} setmetatable(lvim.lsp.popup_border, mt) + ---@deprecated + lvim.lsp.float = {} + setmetatable(lvim.lsp.float, { + __newindex = function(_, k, _) + deprecate("lvim.lsp.float." .. k, "Use `lvim.lsp.handlers.override_config instead.") + end, + }) + ---@deprecated lvim.lang = {} setmetatable(lvim.lang, mt) diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index aea142b8..df06da26 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -79,10 +79,12 @@ return { }, document_highlight = false, code_lens_refresh = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", + handlers = { + override_config = { + focusable = true, + style = "minimal", + border = "rounded", + }, }, on_attach_callback = nil, on_init_callback = nil, diff --git a/lua/lvim/lsp/handlers.lua b/lua/lvim/lsp/handlers.lua index 84f2ba5f..bdd09e4a 100644 --- a/lua/lvim/lsp/handlers.lua +++ b/lua/lvim/lsp/handlers.lua @@ -12,8 +12,12 @@ function M.setup() float = lvim.lsp.diagnostics.float, } vim.diagnostic.config(config) - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lvim.lsp.float) - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lvim.lsp.float) + + if lvim.lsp.handlers.override_config then + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lvim.lsp.handlers.override_config) + vim.lsp.handlers["textDocument/signatureHelp"] = + vim.lsp.with(vim.lsp.handlers.signature_help, lvim.lsp.handlers.override_config) + end end return M -- cgit v1.2.3