Open b-m-f opened 3 months ago
-- Set up nvim-cmp. local cmp = require("cmp") cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) require("luasnip").lsp_expand(args.body) vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) end, }, window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ ["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-Space>"] = cmp.mapping.complete(), ["<C-e>"] = cmp.mapping.abort(), ["<CR>"] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ { name = "path" }, { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, { name = "otter" }, }), }) local capabilities = require("cmp_nvim_lsp").default_capabilities() -- # Rust require("lspconfig")["rust_analyzer"].setup({ capabilities = capabilities, }) require("luasnip.loaders.from_vscode").lazy_load()
The highlighted completion is inserted twice.
Removing the line vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) fixes the issue.
vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
Feels like a bug though. Or is there some behaviour of the native snippets that interferes with lsp completion?
Screencast from 2024-08-14 08-56-45.webm
Use above config on Rust file.
Needs rust-analyzer installed as well as lspconfig.
The highlighted completion is inserted only once.
The highlighted completion is inserted twice
No response
FAQ
Announcement
Minimal reproducible full config
Description
The highlighted completion is inserted twice.
Removing the line
vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
fixes the issue.Feels like a bug though. Or is there some behaviour of the native snippets that interferes with lsp completion?
Screencast from 2024-08-14 08-56-45.webm
Steps to reproduce
Use above config on Rust file.
Needs rust-analyzer installed as well as lspconfig.
Expected behavior
The highlighted completion is inserted only once.
Actual behavior
The highlighted completion is inserted twice
Additional context
No response