diff options
author | CPea <[email protected]> | 2023-03-03 13:28:24 +0700 |
---|---|---|
committer | CPea <[email protected]> | 2023-04-24 19:10:46 +0700 |
commit | bcf24a42b737bfea720326ab84a8b601ca51c7e0 (patch) | |
tree | a9fc7a866ceef70f23400765444ac720b81b8432 | |
parent | 7a4265fa464cc6b2d1e604cb2fded451a2a9adfb (diff) |
refactor(lsp): allow to disable custom handlers config
-rw-r--r-- | lua/lvim/config/_deprecated.lua | 8 | ||||
-rw-r--r-- | lua/lvim/lsp/config.lua | 10 | ||||
-rw-r--r-- | lua/lvim/lsp/handlers.lua | 8 |
3 files changed, 20 insertions, 6 deletions
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 @@ -54,6 +54,14 @@ function M.handle() 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) end 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 |