-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Plugin API Requests #280
Comments
Request: logging api
Current zellij does not provide any logging method (nor for zellij itself except a function for dumping terminal content). As plugin can not simply use
Rust already have many good logging library, such as
lazy_static! {
static ref LOGGER: ZellijPluginLogger = ZellijPluginLogger::default();
}
// ... many codes
impl Log for ZellijPluginLogger {
fn enabled(&self, _: &Metadata) -> bool {
check_zellij_availabre()
}
fn log(&self, record: &Record) {
if self.enabled() { send_log(record) }
// .... many codes
}
}
fn send_log_to_zellij() {
let _ = log::set_logger(&*LOGGER);
}
zellij-tile should provide an API for send log, e.g.
Remaining Problems
|
Make Plugins Configurable #317. |
@horasal Thanks for the suggestion! I think this is certainly a feature I'd like to have in the API eventually! I do have a currently implemented alternative if you're looking for something simple though 🙂 This section of the "Writing a Plugin" guide shows off how simple Rust debugging is possible with the Let me know what you think! |
@TheLostLambda
|
@horasal Let me know what you think about that! Obviously it would be ideal if plugins could also detect flags, but I think that should come with #317 :) |
@TheLostLambda Maybe some sort of message bus/event listener could help (and maybe even remove the need for the timeout and logging)? |
How exactly do you mean? We currently have a sort of event bus system that allows Zellij to send events to plugins, but I suppose that doesn't go both ways yet? For plugins to talk to Zellij, there are just dedicated functions. |
@TheLostLambda I meant something more generic, that can send/receive serializable objects that can be used to pass any data that it may need (other than |
@5c077m4n What new abilities would that give us? Currently things are just sent as JSON over the interface. It's already decently generic I think? |
It sounds great! BTW, I found that json can not serialize things like |
Allow plugins to react to mouse events #607. |
Hey, how do you all feel about metaprogramming Zellij with plugins? Right now the API for plugins seems focused on just getting visual elements painted to the screen to be interacted with. The things I'm interested in doing with plugins involve changing the way Zellij works, rather than presenting information. For instance, I recently wrote a plugin that keeps the current working directory of the focused pane when splitting into a new one. A lot of additions to the core plugin API were needed to make it work though. Basically, the keybinds API was modified to allow for registering actions to be dispatched into plugins instead of being handled by Zellij. Other changes include adding a "PaneUpdate" event that's supposed to function similarly to the TabUpdate event, a plugins manifest in the core config file was added to help with configuring plugins, and an open_terminal method was also introduced. It's quite a lot of changes, and it's pretty hacky and unfinished, but if someone wants to take a look at my fork I can split it into multiple pull requests. As an aside though, can I just say thanks to everyone who contributed to Zellij! I used Tmux for years, but tried Zellij a few weeks ago and now I'm never going back. |
@spacemaison I think adding this sort of "metaprogramming" ability to Zellij plugins is essential! It's actually something that's been on our radar for a little while now but that we've not gotten around to. Things like plugin configuration have been particularly tricky UI problems (would plugin configuration be more at home in the layout or config files, for example?) I'm happy to break things into smaller PRs and merge them in gradually! Is there a particular place that you'd like to start? I've added "Implement Headless Plugins" to the task list at the top of this issue which I think maps to your concept of a "service" plugin :) |
Just a note @spacemaison - while I would totally welcome these changes, IMO the sticky-cwd needs to be the default behaviour of Zellij. There's an open PR for it here: #277 - I think you can pick it up if you like, or start a new one? |
Hey thanks for being receptive to the changes @TheLostLambda. I've opened an issue to add a plugins manifest to Zellij as a place to start. Also thanks for letting me know @imsnif, I'll take a look at that PR and work from there on the issue. |
Dispatching keybound actions into plugins #662 . |
Thoughts on plugins being able to send instructions to zellij? There's already subscribe, but I think going the other way around would be important too. Once mouse events are added, tab bar would have to send an instruction to zellij to change the active tab, right? |
I agree that's a pretty essential feature to have! Currently the way that plugins talk back to Zellij is by calling certain API functions that we expose. Adding one for switching the tab should be relatively simple I think! |
Has any thought been given to dispatching actions back into Zellij from plugins rather than exposing API methods piecemeal? You could just give plugins a impl ZellijPlugin for Whatever {
fn load(&mut self) {
// Creates a new tab and renames it
dispatch_actions(&[
Action::NewTab(None),
Action::TabNameInput("Generated tab".as_bytes().to_vec())
]);
}
} Personally, I don't know if that's kinda ugly or elegant. I already have an open issue for dispatching actions into plugins at #662, and I get the sense @a-kenji thinks it's kinda ugly, so maybe I'm the nutty one here. It'd simplify documentation around what you can do with plugins by quite a bit though, and expand what they can do by a lot. ... A permissions system would absolutely need to be done before this because a plugin author could arbitrarily write whatever they want to the console using |
It seems like sending actions would scale better than having to add functions for each action. I'm not too familiar with how wasm and rust interoperate, but could update and load have a Sender in their parameters? |
@prscoelho @spacemaison I've added this to the official list above! |
Make PluginPanes copyable #721 . |
As a tentative roadmap:
How do people feel about this overall? I should get a chance to give these a swing soon (obviously happy to accept help from others as well)! |
Hey @TheLostLambda, that sounds like a good course of action. How far along are you? I'd be happy to help if you can find a way to divide the work. Every item on that list kinda hangs on the manifest being implemented first though. How are you planning on implementing the manifest? I vaguely recall that we talked about rolling manifest information into the wasm binary somehow, but I can't remember the specifics of what was discussed... |
Ah Firefox wants to randomly log me into the wrong account when I'm not paying attention. For clarities sake that was me @TheLostLambda. |
@spacemaison I'm looking to take a swipe at the manifest this week! It's been a while since I've actually done some coding and I'm eager to give it a go. My plan is to kinda incorporate it with the template plugin repo we have so that the manifest can be maintained as a separate text file (YAML, I suppose) and |
Add action that can send data to a plugin #874 |
Give plugins version information on load #888 |
Feature: add plugin API for File IO #896 |
Reading current directory and command: #1133 |
i want to create a headless plugin that gets details about the layout in a current session. i want to then save this info in a file and load the saved layout the next time zellij is launched if the user wants to. |
Request: allow plugins to aid Zellij to resurrect certain panes. By allowing an plugin to generate the command which shall be used to recreate the pane. |
This issue is meant to be a thread for suggesting / requesting new features in the plugin API. Early plugins will likely require new API to be added, but we'll do our best to be responsive and help add the new API where needed!
Some current things on the docket:
set_timeout(secs)
, allowing the plugin to reschedule its execution (feat(plugin): simple timers implemented via theset_timeout()
call #394)stderr
that is only enabled during--debug
(Zellij needs a logging crate)The text was updated successfully, but these errors were encountered: