blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

Pressing C-Y to accept completions cause luv thread to fail

Open leath-dub opened this issue 1 year ago • 4 comments

Make sure you have done the following

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

Bug Description

This is a strange one, I have the default settings apart from these overrides:

  fuzzy = {
    prebuilt_binaries = {
      download = false,
    }
  },

I am using a nix derivation which compiles "libblink_cmp_fuzzy.so" into $HOME/.nix-profile/lib/libblink_cmp_fuzzy.so", I then add "$HOME/.nix-profile/lib/lib?.so" to my package.cpath`. This seems to work great and I get the completion pop ups on the latest version fine.

The only problem is when I hit <C-y> to accept a completion I get the following error without any trace:

Error in luv thread:                                                                                                                    
module 'blink_cmp_fuzzy' not found:                                                                                                     
        no field package.preload['blink_cmp_fuzzy']                                                                                     
        no file '/nix/store/lbhayvfs66lnrxkrfh2pv6nsqw9qy4vz-luajit-2.1.1713773202-env/share/lua/5.1/blink_cmp_fuzzy.lua'               
        no file '/nix/store/lbhayvfs66lnrxkrfh2pv6nsqw9qy4vz-luajit-2.1.1713773202-env/share/lua/5.1/blink_cmp_fuzzy/init.lua'          
        no file '/nix/store/lbhayvfs66lnrxkrfh2pv6nsqw9qy4vz-luajit-2.1.1713773202-env/lib/lua/5.1/blink_cmp_fuzzy.so'                  
        no file '/home/cathalo/.config/nvim/pack/add/opt/blink.cmp/lua/blink/cmp/fuzzy/../../../../target/release/libblink_cmp_fuzzy.so'
        no file '/home/cathalo/.config/nvim/pack/add/opt/blink.cmp/lua/blink/cmp/fuzzy/../../../../target/release/blink_cmp_fuzzy.so'

This behaviour I can observer on neovim 0.10.2 but also on nightly 0.11.0-dev (I switched to see if it is upstream issue that is already fixed).

Not sure why it errors on not finding package.preload field as that is the first step in a chain that lua require uses, it is not uncommon for package.preload to be nil, right...

Relevant configuration

fuzzy = {
    prebuilt_binaries = {
      download = false,
    }
  },

neovim version

v0.11.0-dev

blink.cmp version: branch, tag, or commit

v0.8.1

leath-dub avatar Dec 22 '24 17:12 leath-dub

Even when I do this:

package.preload["blink_cmp_fuzzy"] = require("blink_cmp_fuzzy")

It still gives same error?? this is very strange

leath-dub avatar Dec 22 '24 17:12 leath-dub

I think I narrowed the issue down to be here https://github.com/Saghen/blink.cmp/blob/main/lua/blink/cmp/fuzzy/init.lua#L27

leath-dub avatar Dec 22 '24 17:12 leath-dub

For now I'll just wrap it in a pcall

leath-dub avatar Dec 22 '24 17:12 leath-dub

Ok so I figured out the issue, ill make a pr that fixes this.

Basically the issue is that package.cpath is not inherited by the worker, this is fine for the standard paths as the rust.lua file will always add these paths whenever it is required. There needs to be a way for the user to be able to specify extra paths, or package.cpath needs to be properly inherited by the worker: which I am not sure why this doesn't happen by default ?

leath-dub avatar Dec 22 '24 18:12 leath-dub