Skip to content

Commit e0e08cb

Browse files
committed
feat: lsp capabilities
1 parent 9b6cb3a commit e0e08cb

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lua/blink/cmp/init.lua

+6
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,10 @@ cmp.snippet_backward = function()
219219
return true
220220
end
221221

222+
--- @param override? lsp.ClientCapabilities
223+
--- @param include_nvim_defaults? boolean
224+
cmp.get_lsp_capabilities = function(override, include_nvim_defaults)
225+
return require('blink.cmp.sources.lib').get_lsp_capabilities(override, include_nvim_defaults)
226+
end
227+
222228
return cmp

lua/blink/cmp/sources/lib/init.lua

+45
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ local config = require('blink.cmp.config')
2020
--- @field get_signature_help fun(context: blink.cmp.SignatureHelpContext, callback: fun(signature_help: lsp.SignatureHelp | nil)): (fun(): nil) | nil
2121
--- @field cancel_signature_help fun()
2222
--- @field reload fun()
23+
--- @field get_lsp_capabilities fun(override?: lsp.ClientCapabilities, include_nvim_defaults?: boolean): lsp.ClientCapabilities
2324

2425
--- @type blink.cmp.Sources
2526
--- @diagnostic disable-next-line: missing-fields
@@ -221,4 +222,48 @@ function sources.reload()
221222
end
222223
end
223224

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+
224269
return sources

0 commit comments

Comments
 (0)