Replies: 195 comments
-
|
I think the most basic demo would be implementing one of the existing commands in such a way, e.g. helix/helix-term/src/commands.rs Lines 123 to 137 in 407b37c It only depends on the Context, and it only uses functions from core (move_horizontally) without interacting with the UI. I think most of the primitives in core should be exposed (selection/range/transaction/etc) and we can have a subset of view exposed (retrieving a selection from a doc, applying transactions)
|
Beta Was this translation helpful? Give feedback.
-
|
Mentioned on Matrix:
|
Beta Was this translation helpful? Give feedback.
-
|
What benefit does this provide over binary plugins? Will plugins be able to access eachother's state (functions, variables etc.) in the same way that plugins programmed in a single language (e.g. emacs) are able to, or something else? My bad if the answer is obvious btw. I'm not very familiar with WebAssembly or plugin architectures. |
Beta Was this translation helpful? Give feedback.
-
I think this post explains it well. There's a lot of uncharted ground in regards to plugin systems, especially with sharing state, but you can see past discussion on this here. |
Beta Was this translation helpful? Give feedback.
-
|
@kirawi |
Beta Was this translation helpful? Give feedback.
-
|
If you want to embed the wasm compiler with the binary or as library etc, I would advise against wasm due to slower speed and missing performance optimisations on many targets. "Of course, wasm3 runs fine on aarch64, but at about 3% of native speed." This benchmark shows very astonishingly the missing optimisations that luajit can do here using this lua libary. Also it would be advisable to have execution time benchmarks of webassembly against all usable alternatives before making a decision (ie by listing some speed and platform compatibility requirements). Would be not very useful to end up with something significantly slower than neovim. |
Beta Was this translation helpful? Give feedback.
-
The intention is to use Lua lacks multithreading, SIMD, and has a smaller ecosystem. It's a lot more convenient to enable users to opt for their favourite language rather than have them learn a separate language and its ecosystem. I can't speak on behalf of everyone, but I believe that most Rustaceans firmly agree with me, as many libraries have wasm as a compile target. I would say we collectively have a lot more experience with wasm as a whole. |
Beta Was this translation helpful? Give feedback.
-
|
We'll probably go with
Given that Cranelift code generator is still very young and already that good, I'm not too afraid. Furthermore performance tracking is a thing at the bytecodealliance. Besides all the other good points made by @kirawi on performance, I really like the ecosystem argument which is the reason why we want to use WASM in the first place. Given that performance is probably good enough (or more than enough), the main focus should be on whether user/developer experience is good. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for considering Wasmer! We are working on a set of benchmarks at the moment, we had two bugs that prevented Wasmer to shine in the one you showcased @CBenoit, but those are already solved in Right now Wasmer is about 20~30% faster than the other runtimes when using the LLVM compiler! In general, we recommend Cranelift if the compilation times need to be fast (that is mainly for development), and LLVM for production (similar to how Rust uses LLVM always to compile in release mode, and Cranelift as an experimental compiler for faster compilation times in debug mode) :) |
Beta Was this translation helpful? Give feedback.
-
This is a question I've had for a while, but what is the main difference between |
Beta Was this translation helpful? Give feedback.
-
|
Thank you @syrusakbary for your input!
I'm interested in hearing more as well! I was more in favor of
On the other hand,
I'll also ask on Veloren's Discord why they decided to use I also found this article published a few months ago:
|
Beta Was this translation helpful? Give feedback.
-
|
@CBenoit @kirawi There are 2 mutual exclusive possible use cases for WASM for plugins, where one really wants to have a plugin manager: 1. shipped compiler or 2. hook into the repo build system and the used compiler to build the WASM libraries/binaries.
Solution 1. gives more of a "it always works" experience with the language that the compiler supports Solution 2. gives more of a "its super fast", but needs some setup and might break. Unless you can use nix for 2. ie with flakes 2 is just painful due to 2.1 many distros not shipping all compilers or only specific versions and then you are stuck on one (ie not yet stable languages) and 2.2 you want to simplify build system stuff for plugin developers. nix with flakes is the de-facto best solution for 2.1 (shipping compilers+libc(s)? and make sure they exist, are configured/build identically and up-to date enough for the plugin ecosystem). Ask yourself which solution is better for the goals of the project helix or how you want to deal with the mess of 1. shipping compilers and 2. supporting the build systems of plugins. |
Beta Was this translation helpful? Give feedback.
-
|
We won't be shipping a compiler, though? WASM is a compile target for Rust itself as Did I understand you correctly? |
Beta Was this translation helpful? Give feedback.
-
|
@kirawi How does this change the problem, when the plugin is written in a language that the distribution doesnt ship a compiler (or super old/incompatible or slow libc etc) ? |
Beta Was this translation helpful? Give feedback.
-
|
No, it's just |
Beta Was this translation helpful? Give feedback.
-
|
@dead10ck Isn't it already happening? @archseer is implementing a scheme on rust. |
Beta Was this translation helpful? Give feedback.
-
is there any repository or pull request to track what is done and what is not ? |
Beta Was this translation helpful? Give feedback.
-
|
did any one check nushell plugins ? |
Beta Was this translation helpful? Give feedback.
-
|
Just putting lapce out there. |
Beta Was this translation helpful? Give feedback.
-
From that webpage: "Vim users, we've got you covered! Built-in support for a Vim like editing experience, without a plugin." |
Beta Was this translation helpful? Give feedback.
-
|
Correct, it supports Vim keybindings without a plugin, but it also supports WASI plugins |
Beta Was this translation helpful? Give feedback.
-
|
Also from that webpage: "WASI plugin system |
Beta Was this translation helpful? Give feedback.
-
|
@devanlooches: Maybe you have some insider information, but I was under the impression they were only slightly further along by having decided on the definite inclusion of a WASI plugin system. But the API and implementation are very not done. lapce/lapce#558 |
Beta Was this translation helpful? Give feedback.
-
|
Ah I see. I only took a quick glance and saw it on the website. I was under the impression it was more completely since there was already a crate on crates.io. lapce-plugin |
Beta Was this translation helpful? Give feedback.
-
|
I believe that this issue would be better served by a proper discussion. I would urge anyone with comments not pertaining to the implementation to use #3806 instead. Additionally, it might be wise to create a new issue altogether for the plugin system. There's a lot of noise here, and focus has shifted from WebAssembly to other alternatives. |
Beta Was this translation helpful? Give feedback.
-
|
@kirawi Discussion is now fragmented between #122, #3806 and #2949 :/ I also agree with #122 (comment), at this point opinions are being repeated and we don't really need more input, rather development time has to be spent on an implementation. |
Beta Was this translation helpful? Give feedback.
-
|
I stumbled upon zellij, which has a WebAssembly plugin system implemented, maybe it can be used as a reference. |
Beta Was this translation helpful? Give feedback.
-
It’s mentioned in the very first post. It’s not against anyone, but for now I think it’s best to lock this issue until further concrete progress is made (see #122 (comment) and #122 (comment) for why). Of course, feel free to comment in the discussion #3806 or to join the Matrix Space, just try to not forget using Ctrl-f in this issue beforehand. I’m not locking to prevent any further discussion from users, but rather to make it obvious to everyone that we already collected most of the opinions and suggestions and that what we really need now is development time. |
Beta Was this translation helpful? Give feedback.
-
|
WebAssembly plugins for Helix would be a significant step — it addresses the biggest limitation (no plugin ecosystem) while staying true to the "safe by default" philosophy that Helix is built around. Why WASM is the right choice for Helix:
The interface design challenge: Performance budget for WASM plugins: Discovery and distribution: The Zed editor has done interesting work on WASM-based extensions — worth examining their architecture choices as a reference. |
Beta Was this translation helpful? Give feedback.
-
|
The WASM plugin system would be transformative for Helix — it's the right architectural choice for a few reasons. Why WASM over Lua/JS:
The tree-sitter + LSP integration makes the interface design interesting: The WASI component model is probably the right foundation here — it's stabilizing and gives you a standard ABI for host functions. Zed is going down a similar path with their extension system. The main design decision is synchrony: do plugin calls block the editor thread? For most operations (syntax transforms, diagnostic filtering) async with a timeout is safest. For key handlers you might need sync with a strict budget (~1ms max). Is there a tracking issue or RFC for this somewhere? I'd love to follow along — we're thinking about something similar for extending AI agent behavior through plugins. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Basically load
.wasmfiles.Capabilities:
At first we could use a basic toml config file or CLI to feed .wasm files to the editor.
A way to configure permissions on a plugin basis could be investigated to use the sandboxing capabilities coming with WASM.
Example with
wasmtime:(reference)
I think the biggest challenge is to get well-defined interfaces down but let's not fear to break it during early stages.
Later we could investigate embedding a wasm-based scripting language such as Grain or AssemblyScript.
Here are some references:
wasmtimeandwasmerI'm willing to experiment soon
Beta Was this translation helpful? Give feedback.
All reactions