Skip to content

Duplicate variable insertion with Erlang Language Platform (ELP) snippet completions #1693

@dandan-eg

Description

@dandan-eg

I'm using Kickstart.nvim with the default blink.cmp setup and the Erlang Language Platform (ELP) LSP server. When accepting a function completion, the argument name is duplicated in the buffer.

Example:

Image

Completing link/1 results in:

% Expected:
link(PidOrPort)

% Got:
link(PidOrPort) PidOrPort

Debug info:

The LSP server returns a valid snippet:

{
  "label": "link/1",
  "insertText": "link(${1:PidOrPort})",
  "insertTextFormat": 2
}

I used transform_items in blink.cmp to confirm this:

sources = {
  default = { 'lsp', 'path', 'snippets', 'lazydev' },
  providers = {
    lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
  },
  transform_items = function(_, items)
    for _, item in ipairs(items) do
      if item.insertText and item.insertTextFormat == 2 then
        item.label = item.insertText
      end
    end
    return items
  end
}

This confirms the snippet is correct by changing the completion label with the snippet, but the argument is inserted twice. It seems to be a bug in how blink.cmp handles snippet expansion, possibly in combination with Kickstart’s default config.

Versions:

Ubuntu 22.04.5 LTS
NVIM v0.11.3
elp-linux-x86_64-unknown-linux-gnu-otp-27.3

Steps to reproduce:

-Create a hello.erl file
-Add an Erlang module:

-module(hello).

start() -> % <- cursor here

-Ensure the ELP LSP server is running
-Start typing "link" and accept the completion "link/1" (C-y by default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions