@@ -20,6 +20,7 @@ local config = require('blink.cmp.config')
20
20
--- @field get_signature_help fun ( context : blink.cmp.SignatureHelpContext , callback : fun ( signature_help : lsp.SignatureHelp | nil )): ( fun (): nil ) | nil
21
21
--- @field cancel_signature_help fun ()
22
22
--- @field reload fun ()
23
+ --- @field get_lsp_capabilities fun ( override ?: lsp.ClientCapabilities , include_nvim_defaults ?: boolean ): lsp.ClientCapabilities
23
24
24
25
--- @type blink.cmp.Sources
25
26
--- @diagnostic disable-next-line : missing-fields
@@ -221,4 +222,48 @@ function sources.reload()
221
222
end
222
223
end
223
224
225
+ function sources .get_lsp_capabilities (override , include_nvim_defaults )
226
+ return vim .tbl_deep_extend (' force' , include_nvim_defaults and vim .lsp .protocol .make_client_capabilities () or {}, {
227
+ textDocument = {
228
+ completion = {
229
+ completionItem = {
230
+ snippetSupport = true ,
231
+ commitCharactersSupport = false , -- todo:
232
+ documentationFormat = { ' markdown' , ' plaintext' },
233
+ deprecatedSupport = true ,
234
+ preselectSupport = false , -- todo:
235
+ tagSupport = { valueSet = { 1 } }, -- deprecated
236
+ insertReplaceSupport = true , -- todo:
237
+ resolveSupport = {
238
+ properties = {
239
+ ' documentation' ,
240
+ ' detail' ,
241
+ ' additionalTextEdits' ,
242
+ ' textEdits' ,
243
+ -- todo: support more properties? should test if it improves latency
244
+ },
245
+ },
246
+ insertTextModeSupport = {
247
+ -- todo: support adjustIndentation
248
+ valueSet = { ' asIs' },
249
+ },
250
+ labelDetailsSupport = true ,
251
+ },
252
+ completionList = {
253
+ itemDefaults = {
254
+ ' commitCharacters' ,
255
+ ' editRange' ,
256
+ ' insertTextFormat' ,
257
+ ' insertTextMode' ,
258
+ ' data' ,
259
+ },
260
+ },
261
+
262
+ contextSupport = true ,
263
+ insertTextMode = ' asIs' ,
264
+ },
265
+ },
266
+ }, override or {})
267
+ end
268
+
224
269
return sources
0 commit comments