mfussenegger / nvim-fzy

Fuzzy picker & vim.ui.select implementation via fzy for neovim
GNU General Public License v3.0
54 stars 4 forks source link

fzy.lua:182: attempt to call upvalue 'on_choice' (a nil value) #41

Closed debeetle closed 10 months ago

debeetle commented 10 months ago

This error occurs to me recently. I change my nvim package manager from minipac to lazy.nvim, and this happens. fzy.lua:182: attempt to call upvalue 'on_choice' (a nil value) Any suggestion will be appreciated.

mfussenegger commented 10 months ago

Sounds like something is calling the fzy execute or pick_one function without providing the on_choice parameter.

Do you get a traceback?

debeetle commented 10 months ago

Sure! Thanks for replying.

stack traceback:
        ...cal/share/nvim/site/pack/paqs/start/nvim-fzy/lua/fzy.lua:193: in function<...cal/share/nvim/site/pack/paqs/start/nvim-fzy/lua/fzy.lua:192>

And line 192 is

192           vim.schedule(function()                                                             
193             on_choice(choice)

Changed the package manager again yesterday, but it does not work right. In case, put my custom fzy configuration below:

#fzycustom.lua
-- some keymap
fzy = require("fzy")
vim.api.nvim_set_keymap(
    "n",
    "<C-s>",
    ":lua fzy.execute('fd . $HOME --hidden --ignore-file $HOME/.config/fd/ignore --type file', fzy.sinks.vs_file)<CR>",
    { silent = true, noremap = true }
)
vim.api.nvim_set_keymap(
    "n",
    "<C-_>",
    ":lua fzy.execute('fd . ./ --hidden --ignore-file $HOME/.config/fd/ignore --type file', fzy.sinks.vs_file)<CR>",
    { silent = true, noremap = true }
)
vim.api.nvim_set_keymap(
    "n",
    "<C-e>",
    ":lua fzy.execute('fd . $HOME --hidden --ignore-file $HOME/.config/fd/ignore --type file', fzy.sinks.edit_file)<CR>",
    { silent = true, noremap = true }
)
vim.api.nvim_set_keymap(
    "n",
    "<C-f>",
    ":lua fzy.execute('fd . $HOME --hidden --ignore-file $HOME/.config/fd/ignore --type d', fzy.sinks.jump)<CR>",
    { silent = true, noremap = true }
)
mfussenegger commented 10 months ago

fzy.sinks.jump and fzy.sinks.vs_file don't exist. That's likely causing the nil error. The second parameter to fzy.execute is called on_choice.

debeetle commented 10 months ago

Thanks for pointing out my stupid question. It turns out I forgot to copy my custom sink function into the new download plugin config. Appreciation for your patience.