Skip to content

Incorrect capabilities injected into lsp config #2385

@jeremimucha

Description

@jeremimucha

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

Versions 1.9.1 and 1.9.0 cause incorrect, at a glance rust-analyzer-related, capabilities to be injected into the lsp configuration. This occurs for all LSPs that I've tried - clangd, lua_ls, pyright, basedpyright.
The issue does not occur on 1.8.0.

Issue occurs on nvim 0.11.0 - the latest version installed in my work environment, sadly I'm currently unable to update.
NAME="Red Hat Enterprise Linux"
VERSION="8.10 (Ootpa)"
ID="rhel"
VERSION_ID="8.10"
ARCH: x86_64

I was unable to reproduce this on my other machine running latest nightly nvim build.
The issue could possibly be related to issue #2379.

Reproduction

Reproduce using the following minimally-edited repro.lua (version pinned + "InsertEnter" load event).
Steps:

  1. nvim -u repro.lua
  2. :e repro.lua
  3. :LspInfo -- lua_ls configuration is the default from lspconfig, capabilities clean
  4. i<Escape> -- enter and quit insert mode - loads blink.cmp
  5. :LspInfo -- lua_ls capabilities extended, include some capabilities incorrect for this lsp, causing it to misbehave, in case of other LSPs causes crashes (e.g. for pyright)

repro.lua:

-- Run with `nvim -u repro.lua`

vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()

---@diagnostic disable-next-line: missing-fields
require('lazy.minit').repro({
  spec = {
    {
      'saghen/blink.cmp',
      version = "1.9.0",  -- also happens on 1.9.1, does not reproduce on 1.8.0
      event = "InsertEnter",
      opts = {},
    },
    {
      'mason-org/mason.nvim',
      build = ':MasonUpdate',
      opts = {},
    },
    {
      'mason-org/mason-lspconfig.nvim',
      dependencies = { 'mason-org/mason.nvim', 'neovim/nvim-lspconfig' },
      opts = {
        ensure_installed = { 'lua_ls' },
      },
    },
  },
})

Configuration before loading blink.cmp:

vim.lsp: Enabled Configurations ~
- lua_ls:
  - cmd: { "lua-language-server" }
  - filetypes: lua
  - root_markers: .emmyrc.json, .luarc.json, .luarc.jsonc, .luacheckrc, .stylua.toml, stylua.toml, selene.toml, selene.yml, .git
  - settings: {
      Lua = {
        codeLens = {
          enable = true
        },
        hint = {
          enable = true,
          semicolon = "Disable"
        }
      }
    }

After loading blink.cmp:

vim.lsp: Enabled Configurations ~
- lua_ls:
  - capabilities: {
      experimental = {
        commands = {
          commands = { "rust-analyzer.showReferences", "rust-analyzer.runSingle", "rust-analyzer.debugSingle" }
        },
        serverStatusNotification = true
      },
      offsetEncoding = { "utf-8", "utf-16" },
      textDocument = {
        completion = {
          completionItem = {
            commitCharactersSupport = false,
            deprecatedSupport = true,
            documentationFormat = { "markdown", "plaintext" },
            insertReplaceSupport = true,
            insertTextModeSupport = {
              valueSet = { 1 }
            },
            labelDetailsSupport = true,
            preselectSupport = false,
            resolveSupport = {
              properties = { "documentation", "detail", "additionalTextEdits", "command", "data" }
            },
            snippetSupport = true,
            tagSupport = {
              valueSet = { 1 }
            }
          },
          completionList = {
            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }
          },
          contextSupport = true,
          editsNearCursor = true,
          insertTextMode = 1
        },
        diagnostic = {
          dynamicRegistration = true,
          relatedDocumentSupport = true
        },
        semanticTokens = vim.NIL
      },
      workspace = {
        configuration = false,
        didChangeWatchedFiles = {
          dynamicRegistration = true
        },
        didChangeWorkspaceFolders = {
          dynamicRegistration = true
        },
        semanticTokens = vim.NIL,
        workspaceFolders = false
      }
    }
  - cmd: { "lua-language-server" }
  - filetypes: lua
  - root_markers: .emmyrc.json, .luarc.json, .luarc.jsonc, .luacheckrc, .stylua.toml, stylua.toml, selene.toml, selene.yml, .git
  - settings: {
      Lua = {
        codeLens = {
          enable = true
        },
        hint = {
          enable = true,
          semicolon = "Disable"
        }
      }
    }

Relevant configuration

neovim version

NVIM v0.11.0 Build type: Release LuaJIT 2.1.1741730670

blink.cmp version

1.9.1, 1.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds more infoWaiting on the author to provide more information

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions