This fork of Neovim aims to add a WASM plugin interface.
This is not to make Neovim able to be compiled into WASM.
Run make
in this top-level directory. The built neovim will be located at
build/bin/nvim
. Try it with build/bin/nvim -u NONE
.
After building the neovim from source, run :wasm <path-to-wasm>
to run a WASM
binary.
There are some example WASM binaries located in wasm/example
. See the README
file for building instructions.
WebAssembly (WASM) is a portable binary format. It is designed to be executed in a sandboxed virtual machines (hosts) safely. Moreover, nearly all programming language can target WASM, this includes C, C++, Rust, and many more.
This implementation uses the following non-standardized features:
- Component Model: Without the component model proposal, we will need to document how data are represented and passed across the virtual machine boundary, and either Neovim or the people writing WASM binary will need to implement the "glue code" translating the representations. The proposal is in Phase 1: Feature Proposal so many changes is likely before this feature is standardized.
Features that will be helpful
- WebAssembly C and C++ API: This will create a common interface for WASM runtimes so it is possible to plug in different runtimes seamlessly.
The current implmementation uses Wasmtime because it seems to be the only one now (2023-06) that supports the component model feature.
The main code for the new WASM module is located at
src/nvim/rust
. It is written in Rust because only Wasmtime
Rust API supports Component model for now (2023-06). The C bindings is located
at src/nvim/wasm
.