blink.compat

repository·main·Indexed 42 days ago

https://github.com/saghen/blink.compat

A compatibility layer that allows blink.cmp users to leverage existing nvim-cmp completion sources. It provides a way to define providers in blink.cmp using the 'blink.compat.source' module to proxy nvim-cmp sources.

Tokens
948
Snippets
3
Records
3
Agent score
3%

What's inside blink.compat

  1. Configure an nvim-cmp source in blink.cmp

    main

    To add an nvim-cmp source to blink.cmp, you must define a provider in the blink.cmp configuration.

    Key requirements:

    1. Set module = 'blink.compat.source'.
    2. Set name to the exact name used by the nvim-cmp source.
    3. If the name you want to use in blink.cmp differs from the nvim-cmp name, use cmp_name to specify the original nvim-cmp name.
    4. Use the opts table within the provider to pass configuration directly to the proxied nvim-cmp source. Note that this opts is distinct from the opts used in a lazy.nvim spec.

    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,
              },
            },
          },
        },
      },
    }
  2. Install blink.compat via lazy.nvim

    main

    To use nvim-cmp sources with blink.cmp, install blink.compat. If you are using blink.cmp version 1.*, you must use blink.compat version 2.*. Setting lazy = true allows lazy.nvim to load the plugin automatically when required by blink.cmp.

    return {
      -- add blink.compat
      {
        'saghen/blink.compat',
        -- use v2.* for blink.cmp v1.*
        version = '2.*',
        -- lazy.nvim will automatically load the plugin when it's required by blink.cmp
        lazy = true,
        -- make sure to set opts so that lazy.nvim calls blink.compat's setup
        opts = {},
      },
      -- ... blink.cmp configuration
    }
  3. Configure blink.compat debug mode

    main

    You can enable debug information in blink.compat to assist with troubleshooting. This is configured via the opts table during setup.

    opts = {
      -- print some debug information. Might be useful for troubleshooting
      debug = false,
    }