Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"..." instead of completion #2086

Closed
2 tasks done
sineptic opened this issue Nov 7, 2024 · 4 comments
Closed
2 tasks done

"..." instead of completion #2086

sineptic opened this issue Nov 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@sineptic
Copy link

sineptic commented Nov 7, 2024

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = " "

local function confirm_completion(fallback)
    if require("cmp").visible() then
        require("cmp").confirm({ select = true, behavior = require("cmp").ConfirmBehavior.Insert })
    else
        fallback()
    end
end
local function select_next_item(fallback)
    if require("cmp").visible() then
        require("cmp").select_next_item()
    else
        fallback()
    end
end
local function select_prev_item(fallback)
    local cmp = require("cmp")
    if cmp.visible() then
        cmp.select_prev_item()
    else
        fallback()
    end
end

require("lazy").setup({
    {
        "hrsh7th/nvim-cmp",
        event = "InsertEnter",
        dependencies = {
            "hrsh7th/cmp-nvim-lsp",
        },
        opts = {
            sources = {
                {
                    name = "nvim_lsp",
                    entry_filter = function(entry)
                        return require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] ~= "Text"
                    end,
                },
            },
            mapping = {
                ["<CR>"] = function(fallback)
                    confirm_completion(fallback)
                end,

                ["<Tab>"] = function(fallback)
                    select_next_item(fallback)
                end,
                ["<S-Tab>"] = function(fallback)
                    select_prev_item(fallback)
                end,
            },
        },
    },
    {
        "mrcjkb/rustaceanvim",
        lazy = false,
        setup = true,
    },
})

Description

with rust:

Screencast.From.2024-11-07.09-33-42.mp4

with python for example(or other):

Screencast.From.2024-11-07.09-36-37.mp4

Steps to reproduce

  1. copy init.lua that I provided
  2. run
nvim -u init.lua main.rs
  1. wait while rust-analyzed loads(~5 secs)
  2. type
fn main() {
    pri // or smth other
}
  1. select not first completion

Expected behavior

work as first completion(only brackets, cursor inside, no ...)

Actual behavior

... inside brackets second brackets after and cursor in them

Additional context

In my config specified rustaceanvim version = "^4" from start.
This issue happens only few month, not from start 100%.
Issue occurs even on version "^3".
So I think issue in your plugin, not rustaceanvim.

@sineptic sineptic added the bug Something isn't working label Nov 7, 2024
@sineptic sineptic changed the title ... instead of completion "..." instead of completion Nov 7, 2024
@hafeoz
Copy link

hafeoz commented Nov 8, 2024

I had encountered the same issue. After lots of trails and errors I've nailed down to snippetSupport LSP capability. Setting

vim.g.rustaceanvim = {
    server = {
        capabilities = {
            textDocument = {
                completion = {
                    completionItem = {
                        snippetSupport = false
                    }
                }
            }
        }
    }
}

solves the issue for me.

Digging the rabbit hole leads me to https://github.com/rust-lang/rust/blob/78bb5ee79e0261e8e47476b631da02acc1cb03ef/src/tools/rust-analyzer/crates/ide-completion/src/render/function.rs#L278 where the seems to came from. I'm not familiar with LSP enough to determine whether it's rust-analyzer's problem, cmp-nvim-lsp's problem or it's purely a config error though.

@sineptic
Copy link
Author

sineptic commented Nov 8, 2024

Thank you, it works, but now snippets, that may be interpreted like lsp completion

For example something.ok<CR> -> Ok(something)

@hafeoz
Copy link

hafeoz commented Nov 10, 2024

OK after some git bisection I've found hrsh7th/cmp-nvim-lsp@44b16d1 to be the culprit. Overriding these properties one by one reveals textEdit to be the offending one.

A quick search then reveals hrsh7th/cmp-nvim-lsp#72 (which has a confusing and unrelated name for those unfamiliar with LSP internals like me...), and using codes from hrsh7th/cmp-nvim-lsp/72#issuecomment-2425963432 solves the issue while allowing snippet completion.

We probably should close this issue as dupe and track the progress on hrsh7th/cmp-nvim-lsp#72?

@sineptic
Copy link
Author

Issue related to another repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants