Skip to content

Commit 40c8801

Browse files
committed
fix: allow defaults to be set to false to disable setting
1 parent 0ab285f commit 40c8801

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

lua/astrolsp/config.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
---@field operations AstroLSPFileOperationsOperationsOpts? enable/disable file operations
5757

5858
---@class AstroLSPDefaultOpts
59-
---@field hover vim.lsp.buf.hover.Opts? control the default options for `vim.lsp.buf.hover()` (`:h vim.lsp.buf.hover.Opts`)
60-
---@field signature_help vim.lsp.buf.signature_help.Opts? control the default options for `vim.lsp.buf.signature_help()` (`:h vim.lsp.buf.signature_help.Opts`)
59+
---@field hover vim.lsp.buf.hover.Opts|false? control the default options for `vim.lsp.buf.hover()` (`:h vim.lsp.buf.hover.Opts`)
60+
---@field signature_help vim.lsp.buf.signature_help.Opts|false? control the default options for `vim.lsp.buf.signature_help()` (`:h vim.lsp.buf.signature_help.Opts`)
6161

6262
---@class AstroLSPMasonLspconfigServer
6363
---@field public package string the Mason package name
@@ -339,10 +339,7 @@ local M = {
339339
capabilities = {},
340340
---@diagnostic disable-next-line: missing-fields
341341
config = {},
342-
defaults = {
343-
hover = {},
344-
signature_help = {},
345-
},
342+
defaults = {},
346343
file_operations = { timeout = 10000, operations = {} },
347344
flags = {},
348345
formatting = { format_on_save = { enabled = true }, disabled = {} },

lua/astrolsp/init.lua

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,21 +353,23 @@ function M.setup(opts)
353353
end
354354

355355
for method, default in pairs(M.config.defaults) do
356-
-- TODO: remove conditional after dropping support for Neovim v0.10
357-
if vim.fn.has "nvim-0.11" == 1 then
358-
local original_method = vim.lsp.buf[method]
359-
if type(original_method) == "function" then
360-
vim.lsp.buf[method] = function(user_opts)
361-
return original_method(vim.tbl_deep_extend("force", default or {}, user_opts or {}))
356+
if default then
357+
-- TODO: remove conditional after dropping support for Neovim v0.10
358+
if vim.fn.has "nvim-0.11" == 1 then
359+
local original_method = vim.lsp.buf[method]
360+
if type(original_method) == "function" then
361+
vim.lsp.buf[method] = function(user_opts)
362+
return original_method(vim.tbl_deep_extend("force", default, user_opts or {}))
363+
end
364+
end
365+
else
366+
local deprecated_handler = ({
367+
hover = "textDocument/hover",
368+
signature_help = "textDocument/signatureHelp",
369+
})[method]
370+
if deprecated_handler and default then
371+
vim.lsp.handlers[deprecated_handler] = vim.lsp.with(vim.lsp.handlers[deprecated_handler], default)
362372
end
363-
end
364-
else
365-
local deprecated_handler = ({
366-
hover = "textDocument/hover",
367-
signature_help = "textDocument/signatureHelp",
368-
})[method]
369-
if deprecated_handler and default then
370-
vim.lsp.handlers[deprecated_handler] = vim.lsp.with(vim.lsp.handlers[deprecated_handler], default)
371373
end
372374
end
373375
end

0 commit comments

Comments
 (0)