lua: accepting completion may erroneusly overwrite text
Opened this issue · 1 comments
Make sure you have done the following
- I have updated to the latest version of
blink.cmp
- I have read the README
Bug Description
- Write below config to
tmp.lua
- Source below config with
nvim -u tmp.lua
- Enter
local blink = require "
, completion appears - Accept
blink
with<C-y>
- See
"
being erroneously overwritten
Screenshot for 3.
Screenshot for 4.
I can imagine this is a gnarly one, because expected behavior is presumably somewhat lua-specific, as in other contexts users do expect prefixes (in this case "
to be overwritten).
Relevant configuration
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = "/tmp/nvim/site/pack"
local lazypath = package_root .. "/lazy/lazy.nvim"
local pluginpath = package_root .. "/plugins/"
if not vim.loop.fs_stat(lazypath) then
print "Installing 'folke/lazy.nvim'..."
vim.fn.system { "git", "clone", "https://github.com/folke/lazy.nvim.git", lazypath }
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"saghen/blink.cmp",
lazy = false,
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = { preset = "default" },
appearance = {
use_nvim_cmp_as_default = true,
nerd_font_variant = "mono",
},
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
signature = { enabled = true },
},
opts_extend = { "sources.default" },
},
{
"neovim/nvim-lspconfig",
config = function()
local lsp = vim.lsp
local lspconfig = require "lspconfig"
local capabilities = lsp.protocol.make_client_capabilities()
capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
lspconfig.lua_ls.setup {
capabilities = capabilities,
}
end,
},
}, { root = pluginpath })
neovim version
NVIM v0.11.0-dev-1376+g738320188f Build type: Release LuaJIT 2.1.0-beta3 Run "nvim -V1 -v" for more info
blink.cmp
version: branch, tag, or commit
main
I noticed this when trying to autocomplete a path, like when typing "/home/user/W"
then using autocomplete to choose Workspace
autocomplete would replace previous path elements e.g. resulting in "/home/Workspace"
replacing the user part.
However this seems to not happen, when properly accepting the autocompletion entries every time. So typing "/ho"
then accepting home, then selecting and accepting user/
and then selecting and accepting Workspace/
works fine for me.
The error instead occurs for me when using auto_insert
. Then typing "/ho"
selecting home
to auto_insert it, keep typing "us"
then selecting user/
might auto insert it not at the end but at the beginning, replacing home
.