stevearc / dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
MIT License
1.7k stars 32 forks source link

fix: error on first fzf-lua run #65

Closed illia-danko closed 1 year ago

illia-danko commented 1 year ago

Fix fzf_lua backend error

Context

The error popup:

Error executing vim.schedule lua callback: ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: attempt to call a nil value
stack traceback:
        ...cker/start/dressing.nvim/lua/dressing/select/fzf_lua.lua:30: in function 'select'
        .../packer/start/dressing.nvim/lua/dressing/select/init.lua:63: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Description

Since fzf_lua is lazily loading the api on any built-in command execution, we need explicitly load fzf-lua.core module to exercise the api directly, without relying on lazy loading.

Test Plan

The issue discovered on ziontee113/icon-picker.nvim with basic packer configuration:

use({
    "ziontee113/icon-picker.nvim",
    requires = { "stevearc/dressing.nvim" },
    config = config.icon_picker,
  })
  ...
  M.icon_picker = function()
  require("icon-picker").setup({})
end
  1. Setup ziontee113/icon-picker.nvim
  2. Restart neovim
  3. Run :IconPickerInsert from neovim command prompt.
stevearc commented 1 year ago

Thanks for putting in a fix! In this instance, the root cause is actually a bug in fzf-lua (https://github.com/ibhagwan/fzf-lua/pull/522). I'd prefer to fix it there instead of hacking around it in dressing.nvim

ibhagwan commented 1 year ago

Ty @stevearc, I apologize for missing this.