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

lua: accepting completion may erroneusly overwrite text #634

Open
2 tasks done
fdschmidt93 opened this issue Dec 18, 2024 · 1 comment
Open
2 tasks done

lua: accepting completion may erroneusly overwrite text #634

fdschmidt93 opened this issue Dec 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fdschmidt93
Copy link

fdschmidt93 commented Dec 18, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

  1. Write below config to tmp.lua
  2. Source below config with nvim -u tmp.lua
  3. Enter local blink = require ", completion appears
  4. Accept blink with <C-y>
  5. See " being erroneously overwritten

Screenshot for 3.

image

Screenshot for 4.

image

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

@fdschmidt93 fdschmidt93 added the bug Something isn't working label Dec 18, 2024
@fdschmidt93 fdschmidt93 changed the title lua: accepting may erroneusly overwrite text lua: accepting completion may erroneusly overwrite text Dec 18, 2024
@ddogfoodd
Copy link

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.

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