-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Acessing state
in plugin's setup
function
#703
Comments
This is a bit off topic, but in the example that I gave I'm using Do you want me to make a PR to fix this? |
Thank you for the report, this is a known issue, and I am still considering how to address it. You can use return {
setup = function(self, opts)
local st = state("your-plugin-name")
st.foo = "bar"
end
} Needs 0cb572a |
Yeah, please raise a PR for it! |
Cool, thanks for the quick workaround, I'll use it in the mean time. |
Hi, I made a PR trying to fix it, #710, let me know if it works for you! |
I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
What system are you running Yazi on?
Linux Wayland
What terminal are you running Yazi in?
wezterm 20240123-102946-02bdd7ed
Yazi version
yazi 0.2.3 (8efafd6 2024-02-19)
Did you try the latest main branch to see if the problem got fixed?
Tried, but the problem still
Describe the bug
Yazi panics when trying to access the
state
variable inside asetup
function as demonstrated in https://yazi-rs.github.io/docs/plugins/overview#sync-vs-async.Expected Behavior
It should be possible to set variables in the
state
so that the plugins can have custom configurations.To Reproduce
I've created a new branch in bookmarks.yazi which has a simple
setup
function that tries to set a table in thestate
variable.To recreate the issue, simply call the
setup
method ininit.lua
Configuration
No response
Anything else?
I've looked a bit into the lua API and I think that the issue is because the
require
just runs the lua code without the context ofYAZI_PLUGIN_NAME
.A possible solution might be to have a custom
require
that does something similar to entry.The text was updated successfully, but these errors were encountered: