Closed iovis closed 1 year ago
But doing so caused the following backtrace:
That’s because most likely it’s not possible to recursively copy the previewer class, can you try like this?
M.default_opts = {
prompt = "muxi sessions> ",
previewer = { _ctor = SessionPreviewer },
}
This way only one function is copied (class instantiation) as opposed to the entire class metatable.
---@class MuxiFzfSessionManagerOpts
M.default_opts = {
prompt = "muxi sessions> ",
-- previewer = SessionPreviewer, -- TODO: stack overflow?
previewer = { _ctor = SessionPreviewer },
actions = {
Same issue unfortunately
What about:
---@class MuxiFzfSessionManagerOpts
M.default_opts = {
prompt = "muxi sessions> ",
-- previewer = SessionPreviewer, -- TODO: stack overflow?
previewer = { _ctor = SessionPreviewer.new },
E5108: Error executing lua: ...david/Sites/vim/muxi.nvim/lua/muxi/fzf/sessions/init.lua:59: ...hare/nvim/lazy/fzf-lua/lua/fzf-lua/previewer/builtin.lua:24: attempt to index local 'self' (a nil value)
stack traceback:
[C]: in function 'fzf_exec'
...david/Sites/vim/muxi.nvim/lua/muxi/fzf/sessions/init.lua:59: in function <...david/Sites/vim/muxi.nvim/lua/muxi/fzf/sessions/init.lua:32>
Being sessions/init.lua:59
[Source]:
fzf_lua.fzf_exec(contents, opts)
Let me get back to you on that, being away from my computer I was doing some guesswork, I’ll test it myself next time I’m on the computer and let you know.
I remembered I has a workaround to having to copying the class __index
, using _ctor
, I was close, this way only the function gets copied instead of the entire class object:
M.default_opts = {
prompt = "muxi sessions> ",
previewer = { _ctor = function() return SessionPreviewer end },
}
That fixed it, you're the best. Thank you!
@ibhagwan I am facing the same problem after 61d7f1763828. Thanks the issues query brings me here.
@ibhagwan I am facing the same problem after 61d7f17. Thanks the issues query brings me here.
Can you try with the latest commit https://github.com/ibhagwan/fzf-lua/commit/4e861e4f91314f1f5108791201a45bff6c6abbf5? Although the error is stack overflow
this is a different issue that was fixed by #1398.
@ibhagwan Ok, the latest commit fix it. Thank you!
Info
nvim --version
: v0.9.1fzf --version
: 0.42.0Description
Hey @ibhagwan! I was toying around with a custom previewer for my plugin, muxi.nvim, and I think I'm not registering my previewer correctly.
Unlike the last time, this previewer is a bit more custom (relies on implementation details of my plugin) and it doesn't seem like using an out of the box one is an option. It'll take a path and generate a prettified representation of a lua table associated with it:
The previewer seems to be working great, your docs were very helpful. The one thing that's tripping me up is how to register it as the default previewer.
Basically I had tried the following:
But doing so caused the following backtrace:
However, if instead of declaring it as default opts I just pass it, like so:
Then everything works great.
What's the proper way of registering a default custom previewer for a command?
Thank you!