nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.36k stars 45 forks source link

Error with prompt_cache when using gkeep extension #40

Closed piotr-serafin-red closed 2 years ago

piotr-serafin-red commented 2 years ago

Describe the bug Cannot search google keep notes with telescope, following errors (from fzf-native) are shown:

error caught while executing async callback:
NvimError("Error executing lua: ...escope-fzf-native.nvim/lua/telescope/_extensions/fzf.lua:25: attempt to index field 'prompt_cache' (a nil value)")
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pynvim/api/nvim.py", line 320, in exec_lua
    return self.request('nvim_execute_lua', code, args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pynvim/api/nvim.py", line 182, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
    raise self.error_wrapper(err)
pynvim.api.common.NvimError: Error executing lua: ...escope-fzf-native.nvim/lua/telescope/_extensions/fzf.lua:25: attempt to index field 'prompt_cache' (a nil value)

the call was requested at
  File "/Users/piotr_serafin/.local/share/nvim/site/pack/packer/start/gkeep.nvim/rplugin/python3/gkeep/thread_util.py", line 56, in w
    func(*args, **kwargs)
  File "/Users/piotr_serafin/.local/share/nvim/site/pack/packer/start/gkeep.nvim/rplugin/python3/gkeep/status.py", line 43, in d
    return f(*args, **kwargs)
  File "/Users/piotr_serafin/.local/share/nvim/site/pack/packer/start/gkeep.nvim/rplugin/python3/gkeep/api.py", line 186, in run_search
    callback()
  File "/Users/piotr_serafin/.local/share/nvim/site/pack/packer/start/gkeep.nvim/rplugin/python3/gkeep/plugin.py", line 501, in respond
    self._vim.async_call(

To Reproduce Steps to reproduce the behavior:

  1. Perform succesfull GkeepLogin
  2. Add telescope integration by adding: require('telescope').load_extension('gkeep')
  3. Execute :Telescope gkeep
  4. See error

Expected behavior List of notes available in Telescope window

Version information

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.1/share/nvim"

 - Gkeep:

health#gkeep#check

gkeep

Additional context Configured telescope extensions

require('telescope').load_extension('fzf')
require('telescope').load_extension('dap')
require('telescope').load_extension('gkeep')

It seems that there is a problem with fzf extension. When removed (by commenting require('telescope').load_extension('fzf')) gkeep search in telescope works perfectly fine.

Screenshots image

Links:

Conni2461 commented 2 years ago

I hardly believe this is a bug here. gkeep does some fishy things here

https://github.com/stevearc/gkeep.nvim/blob/333e788651adcaff331ca1fdca7d966f0ac87bbb/lua/telescope/_extensions/gkeep.lua#L107-L111

They creates a empty sorter and only calls my scoring function but i NEED a init step that is now missing. Sooooo nothing that can be fixed here.

What they can do is not create a empty sorter but creating a generic sorter and replacing the scoring function of that but they CANT leave out my init function. It also leaves out my destroy function, which would result in a memory leak.

So yeah these two functions are essential https://github.com/nvim-telescope/telescope-fzf-native.nvim/blob/59e38e1661ffdd586cb7fc22ca0b5a05c7caf988/lua/telescope/_extensions/fzf.lua#L44-L57

Conni2461 commented 2 years ago

Alternatively they could do

local fuzzy = conf.generic_sorter(opts)
local sorter = sorters.Sorter:new {
    init = function(self)
      fuzzy.init(self)
    end,
    destroy = function(self)
      fuzzy.destroy(self)
    end,
    start = function(self, prompt)
      fuzzy.start(self, prompt)
    end,
    discard = fuzzy.discard,
    scoring_function = function(self, prompt, line)
      fuzzy.scoring_function(self, modified_prompt, line)
    end,
    -- depending if they want highlighter or not
    highlighter = function(self, prompt, display)
      fuzzy.highlighter(self, prompt, display)
    end,
  }
end

This is not a issue here they just have to provide the full interface. (above might work. I havent tested it.)

piotr-serafin-red commented 2 years ago

Thx, closing this issue and forward info to gkeep.nvim maintainer.