Skip to content
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

feat(wasm-plugin-system): major overhaul and some goodies #2510

Merged
merged 23 commits into from
Jun 7, 2023

Conversation

imsnif
Copy link
Member

@imsnif imsnif commented Jun 7, 2023

Intro

While after this there's still some major work that needs to be done for the plugin system, this PR makes developing Rust plugins possible for the pioneering developer. More details will be given upon release in the documentation.

All changes in this PR

Strider now has a Fuzzy Find for file names (and contents!)

2023-05-22_09-39-11.mp4

This is included as a sort of "hidden feature", mainly for the purposes of being a proof of concept for a complex plugin. This feature uses the plugin workers to offload heavy work from the update/render loop. Namely scanning the HD (which is a bit slow with wasmer 2.X, but will be addressed in a future PR) and doing the actual search.

It also uses the new plugin API methods mentioned below to open a file in the user's $EDITOR (to the relevant line), tiled or floating, and also to open a new terminal pane to the file's location (tiled or floating).

It's a bit rough (being mostly a POC), but I personally plan to use it. To access it, open Strider and type / followed by your search term.

When a plugin crashes it no longer crashes Zellij

img-2023-06-07-113511

Instead, we'll display a stack trace on the plugin pane (as well as in the logs) as seen in the above screenshot. (Thanks @har7an for the nice cross-wasm-boundary stack traces).

Plugin workers stay alive

The register_worker macro in zellij-tile now also accepts a static variable where it will store its state. This means that the workers stay alive and don't need to serialize themselves to the HD. It also means that we don't constantly spawn extra async tasks when sending them messages and waiting on them. Which improves performance quite a bit.

New Plugin API methods

  • open_file_floating - like the existing open_file but floating - opens the user's $EDITOR to the specified file in a new pane, but in a new floating pane
  • open_file_with_line, open_file_with_line_floating - open's the user's $EDITOR to the specified file (and line, if the editor supports it - most do) in either a new tiled or floating pane
  • open_terminal, open_terminal_floating - open a new terminal pane (tiled or floating) to the specified CWD

New Plugin Events

Plugins can now subscribe to four file system events (in the folder Zellij was started from): FileSystemCreate(paths), FileSystemRead(paths), FileSystemUpdate(paths), FileSystemDelete(paths)

New CLI Action LaunchOrFocusPlugin

This CLI (or keybind) action will accept a plugin path (either a built-in Zellij plugin or a static path on the HD to a wasm file) and then either focus a pane with this plugin if it is already loaded or open a pane (tiled or floating) and load the plugin inside it.

This is useful for "kiosk" like plugins that appear for a certain task and then hide themselves (eg. the Strider fuzzy file search above) - eg. pressing F1 will load or focus said plugin.

@imsnif imsnif temporarily deployed to cachix June 7, 2023 10:24 — with GitHub Actions Inactive
@imsnif imsnif temporarily deployed to cachix June 7, 2023 10:24 — with GitHub Actions Inactive
@imsnif imsnif merged commit c11d75f into main Jun 7, 2023
renovate bot referenced this pull request in scottames/dots Jun 19, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [aquaproj/aqua-registry](https://togithub.com/aquaproj/aqua-registry)
| minor | `v4.19.0` -> `v4.20.0` |
| [zellij-org/zellij](https://togithub.com/zellij-org/zellij) | minor |
`v0.36.0` -> `v0.37.0` |

---

### Release Notes

<details>
<summary>aquaproj/aqua-registry</summary>

###
[`v4.20.0`](https://togithub.com/aquaproj/aqua-registry/releases/tag/v4.20.0)

[Compare
Source](https://togithub.com/aquaproj/aqua-registry/compare/v4.19.0...v4.20.0)


[Issues](https://togithub.com/aquaproj/aqua-registry/issues?q=is%3Aissue+milestone%3Av4.20.0)
| [Pull
Requests](https://togithub.com/aquaproj/aqua-registry/pulls?q=is%3Apr+milestone%3Av4.20.0)
| aquaproj/aqua-registry@v4.19.0...v4.20.0

#### 🎉 New Packages


[#&#8203;13132](https://togithub.com/aquaproj/aqua-registry/issues/13132)
[segmentio/golines](https://togithub.com/segmentio/golines): A golang
formatter that fixes long lines
[@&#8203;iwata](https://togithub.com/iwata)

#### Fixes


[#&#8203;13143](https://togithub.com/aquaproj/aqua-registry/issues/13143)
[terraform-linters/tflint](https://togithub.com/terraform-linters/tflint):
Support old versions

</details>

<details>
<summary>zellij-org/zellij</summary>

###
[`v0.37.0`](https://togithub.com/zellij-org/zellij/releases/tag/v0.37.0)

[Compare
Source](https://togithub.com/zellij-org/zellij/compare/v0.36.0...v0.37.0)

In this release we've done a lot of work on our WebAssembly / WASI
plugin system and are very excited to invite adventurous Rust developers
to come pioneer our plugin system with us. To read more, please see the
official [Plugin
Documentation](https://zellij.dev/documentation/plugins.html).

Please also drop by our Discord or Matrix and show us the plugins you're
working on!

#### Other Highlights

- Some basic themes are now included with the release, give it a try by
starting Zellij with `zellij options --theme catppuccin-mocha`
-   Layouts now support environment variables and tilde expansions
-   We can now provide a `--cwd` option when starting Zellij

#### All changes

- fix(plugin): respect hide session option on compact-bar by
[@&#8203;pedromfedricci](https://togithub.com/pedromfedricci) in
[https://github.com/zellij-org/zellij/pull/2368](https://togithub.com/zellij-org/zellij/pull/2368)
- feat: Add layout configuration to exclude panes from tab sync by
[@&#8203;on3iro](https://togithub.com/on3iro) in
[https://github.com/zellij-org/zellij/pull/2314](https://togithub.com/zellij-org/zellij/pull/2314)
- Fix 2205 - Support cwd by
[@&#8203;Kangaxx-0](https://togithub.com/Kangaxx-0) in
[https://github.com/zellij-org/zellij/pull/2290](https://togithub.com/zellij-org/zellij/pull/2290)
- feat(plugins): reload plugin at runtime by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2372](https://togithub.com/zellij-org/zellij/pull/2372)
- Update architecture doc by
[@&#8203;Kangaxx-0](https://togithub.com/Kangaxx-0) in
[https://github.com/zellij-org/zellij/pull/2371](https://togithub.com/zellij-org/zellij/pull/2371)
- feat(themes): add nightfox themes by
[@&#8203;EdenEast](https://togithub.com/EdenEast) in
[https://github.com/zellij-org/zellij/pull/2384](https://togithub.com/zellij-org/zellij/pull/2384)
- feat: provide default themes by
[@&#8203;jaeheonji](https://togithub.com/jaeheonji) in
[https://github.com/zellij-org/zellij/pull/2307](https://togithub.com/zellij-org/zellij/pull/2307)
- feat(plugins): update and render plugins asynchronously by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2410](https://togithub.com/zellij-org/zellij/pull/2410)
- feat(layout): Support environment variables in cwd
([#&#8203;2288](https://togithub.com/zellij-org/zellij/issues/2288)) by
[@&#8203;shahamran](https://togithub.com/shahamran) in
[https://github.com/zellij-org/zellij/pull/2291](https://togithub.com/zellij-org/zellij/pull/2291)
- Add file path context to all IO errors in ConfigError by
[@&#8203;Imberflur](https://togithub.com/Imberflur) in
[https://github.com/zellij-org/zellij/pull/2412](https://togithub.com/zellij-org/zellij/pull/2412)
- fix(e2e): fix flaky locked mode test by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2413](https://togithub.com/zellij-org/zellij/pull/2413)
- Fix error loading non-existant themes directory and use default themes
as the base when merging by
[@&#8203;Imberflur](https://togithub.com/Imberflur) in
[https://github.com/zellij-org/zellij/pull/2411](https://togithub.com/zellij-org/zellij/pull/2411)
- improve build/ci times by
[@&#8203;tlinford](https://togithub.com/tlinford) in
[https://github.com/zellij-org/zellij/pull/2396](https://togithub.com/zellij-org/zellij/pull/2396)
- Do not unwrap() the sticky bit setting! by
[@&#8203;valpackett](https://togithub.com/valpackett) in
[https://github.com/zellij-org/zellij/pull/2424](https://togithub.com/zellij-org/zellij/pull/2424)
- Use rust 1.67 by [@&#8203;har7an](https://togithub.com/har7an) in
[https://github.com/zellij-org/zellij/pull/2375](https://togithub.com/zellij-org/zellij/pull/2375)
- Fix issue 2421 - Update config file output by
[@&#8203;Kangaxx-0](https://togithub.com/Kangaxx-0) in
[https://github.com/zellij-org/zellij/pull/2443](https://togithub.com/zellij-org/zellij/pull/2443)
- feat(plugins): Plugin workers and strider by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2449](https://togithub.com/zellij-org/zellij/pull/2449)
- fix: cwd of newtab action by
[@&#8203;onichandame](https://togithub.com/onichandame) in
[https://github.com/zellij-org/zellij/pull/2455](https://togithub.com/zellij-org/zellij/pull/2455)
- feat(wasm-plugin-system): major overhaul and some goodies by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2510](https://togithub.com/zellij-org/zellij/pull/2510)
- feat(plugins): extensive plugin api by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2516](https://togithub.com/zellij-org/zellij/pull/2516)
- fix: runtime panic because of local cache by
[@&#8203;jaeheonji](https://togithub.com/jaeheonji) in
[https://github.com/zellij-org/zellij/pull/2522](https://togithub.com/zellij-org/zellij/pull/2522)
- fix(output): do not hide cursor on a render that does not include
visual assets by [@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2528](https://togithub.com/zellij-org/zellij/pull/2528)
- fix(screen): focus tab as well as pane when launching existing plugin
by [@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2530](https://togithub.com/zellij-org/zellij/pull/2530)
- fix(strider): clear search term on ESC by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2531](https://togithub.com/zellij-org/zellij/pull/2531)
- fix(plugins): only listen to hd if a plugin is subscribed to hd events
by [@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2529](https://togithub.com/zellij-org/zellij/pull/2529)
- fix(logs): suppress debug logs when not debugging by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2532](https://togithub.com/zellij-org/zellij/pull/2532)
- fix(plugins): allow loading relative urls by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2539](https://togithub.com/zellij-org/zellij/pull/2539)
- feat(plugins): plugin pane state events by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2545](https://togithub.com/zellij-org/zellij/pull/2545)
- performance(plugins): use a debounced fs watcher by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2546](https://togithub.com/zellij-org/zellij/pull/2546)
- feat(plugins): more plugin api methods by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2550](https://togithub.com/zellij-org/zellij/pull/2550)
- refactor(plugins): improve api by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2552](https://togithub.com/zellij-org/zellij/pull/2552)
- feat(plugins): strider improvements by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2551](https://togithub.com/zellij-org/zellij/pull/2551)
- docs(plugins): document the zellij-tile events and commands api by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2554](https://togithub.com/zellij-org/zellij/pull/2554)
- docs(plugins): better zellij-tile-docs by
[@&#8203;imsnif](https://togithub.com/imsnif) in
[https://github.com/zellij-org/zellij/pull/2560](https://togithub.com/zellij-org/zellij/pull/2560)

#### New Contributors

- [@&#8203;on3iro](https://togithub.com/on3iro) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2314](https://togithub.com/zellij-org/zellij/pull/2314)
- [@&#8203;Kangaxx-0](https://togithub.com/Kangaxx-0) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2290](https://togithub.com/zellij-org/zellij/pull/2290)
- [@&#8203;EdenEast](https://togithub.com/EdenEast) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2384](https://togithub.com/zellij-org/zellij/pull/2384)
- [@&#8203;shahamran](https://togithub.com/shahamran) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2291](https://togithub.com/zellij-org/zellij/pull/2291)
- [@&#8203;Imberflur](https://togithub.com/Imberflur) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2412](https://togithub.com/zellij-org/zellij/pull/2412)
- [@&#8203;valpackett](https://togithub.com/valpackett) made their first
contribution in
[https://github.com/zellij-org/zellij/pull/2424](https://togithub.com/zellij-org/zellij/pull/2424)
- [@&#8203;onichandame](https://togithub.com/onichandame) made their
first contribution in
[https://github.com/zellij-org/zellij/pull/2455](https://togithub.com/zellij-org/zellij/pull/2455)

**Full Changelog**:
zellij-org/zellij@v0.36.0...v0.37.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/scottames/dots).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMjYuMCIsInVwZGF0ZWRJblZlciI6IjM1LjEyNi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant