Configure an nvim-cmp source in blink.cmp
mainTo add an nvim-cmp source to blink.cmp, you must define a provider in the blink.cmp configuration.
Key requirements:
- Set
module = 'blink.compat.source'. - Set
nameto the exact name used by thenvim-cmpsource. - If the
nameyou want to use inblink.cmpdiffers from thenvim-cmpname, usecmp_nameto specify the originalnvim-cmpname. - Use the
optstable within the provider to pass configuration directly to the proxiednvim-cmpsource. Note that thisoptsis distinct from theoptsused in alazy.nvimspec.
Warning: Do not use blink.compat for buffer, snippets, path, or lsp sources, as blink.cmp provides native, more efficient equivalents for these.
-- Example: adding cmp-digraphs to blink.cmp via lazy.nvim
return {
{ 'saghen/blink.compat', version = '2.*', lazy = true, opts = {} },
{
'saghen/blink.cmp',
version = '1.*',
dependencies = {
{ 'dmitmel/cmp-digraphs' },
},
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer', 'digraphs' },
providers = {
digraphs = {
-- IMPORTANT: use the same name as you would for nvim-cmp
name = 'digraphs',
module = 'blink.compat.source',
-- blink.cmp source config options work as normal
score_offset = -3,
-- This table is passed directly to the proxied completion source
-- as the `option` field in nvim-cmp's source config
opts = {
cache_digraphs_on_start = true,
},
},
},
},
},
}