Skip to content

Commit 193423c

Browse files
committed
fix: check LSP methods before requesting
closes #220
1 parent a078c87 commit 193423c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/blink/cmp/sources/lsp.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ function lsp:has_capability(capability)
1616
return false
1717
end
1818

19+
--- @param method string
20+
--- @return boolean Whether at least one LSP client supports `method`
21+
--- @private
22+
function lsp:has_method(method) return #vim.lsp.get_clients({ bufnr = 0, method = method }) > 0 end
23+
1924
--- Completion ---
2025

2126
function lsp:get_trigger_characters()
@@ -48,7 +53,7 @@ function lsp:get_completions(context, callback)
4853
-- TODO: should make separate LSP requests to return results earlier, in the case of slow LSPs
4954

5055
-- no providers with completion support
51-
if not self:has_capability('completionProvider') then
56+
if not self:has_capability('completionProvider') or not self:has_method('textDocument/completion') then
5257
callback({ is_incomplete_forward = false, is_incomplete_backward = false, items = {} })
5358
return function() end
5459
end
@@ -196,6 +201,12 @@ function lsp:get_signature_help_trigger_characters()
196201
end
197202

198203
function lsp:get_signature_help(context, callback)
204+
-- no providers with signature help support
205+
if not self:has_method('textDocument/signatureHelp') then
206+
callback(nil)
207+
return function() end
208+
end
209+
199210
local params = vim.lsp.util.make_position_params()
200211
params.context = {
201212
triggerKind = context.trigger.kind,

0 commit comments

Comments
 (0)