Nev

Plugins

This describes the new plugin system. For documentation about the old system go here

Nev uses wasm for plugins. In theory any language can be used but an auto generated plugin api is only provided for Nim.

Nim is compiled to wasm using Emscripten.

Installing plugins

Plugins are loaded from app://plugins (builtin plugins) and home://.nev/plugins (user plugins). You should install plugins into home://.nev/plugins.

Plugin API versions

Nev can support multiple versions of the plugin API. For now only two versions will be supported:

Once the new plugin API has stabilized somewhat we will probably switch to another model:

In this new model Nev will support some amount of older versions (probably around two or three, depending on how much effort it is to keep supporting them). Support for older versions might also be dropped when builtin features get changed enough where supporting the old API would be too much work.

The main goal with supporting multiple versions is not backwards compatibility forever, but to provide more time before plugins have to be updated when the plugin API changes.

Plugin structure

Each plugin consists of at least a manifest.json and a wasm binary.

Here is an example of a manifest:

{
    "name": "My plugin",
    "version": "0.0.1",
    "authors": ["Your name"],
    "repository": "https://github.com/abc/xyz",
    "wasm": "plugin.m.wasm",  // You can also use .wat files (wasm in text format)
    "autoLoad": false,        // Set to true to load the plugin automatically when opening the editor
    "commands": {             // Declare which commands are exported by the plugin
        "test-command-1": {},
        "test-command-2": {
            "parameters": [{"name": "a", "type": "string"}],
            "returnType": "string",
            "description": "Does something",
        }
    },
    "permissions": {          // Default permissions. Can be overriden by user who installs the plugin.
        "filesystem": {
            "disallowAll": false,
            "allow": ["ws0://"],
        },
        "commands": {
            "allowAll": true,
        },
    }
}

Override plugin permissions

To override the permissions for a plugin you need so set the plugin.<plugin-id>.permissions setting. The plugin-id is the name of the folder which contains the plugin manifest.

// In e.g. home://.nev/settings.json
// Override permissions for home://.nev/plugins/my_plugin/manifest.json
{
    "plugin.my_plugin.permissions": {
        "filesystemRead": {
             // Different ways of specifying the permissions, in order of highest priority to lowest priority.
            "disallowAll": false,      // If this is true it disallows any access, overriding any other settings for this category. Default: false,
            "disallow": ["ws0://src"], // Explicitly list disallowed paths. These are prefixes. Paths are normalized before checking the permissions to prevent accessing paths in parent directories using '..'
            "allowAll": false,         // Allow accessing all paths (except paths in 'disallow')
            "allow": ["ws0://src"],    // Explicitly list allowed paths (only used if 'allowAll' is false)
        },
        "filesystemWrite": {
            // If nothing is specified then the plugin has no permissions for this category
        },
        "commands": {
            "allowAll": false,
        },
    },
    "plugin.some_shady_plugin.permissions": {}, // Empty, give this plugin no permissions
}

WASI

Nev supports selecting which WASI implementation to use for each plugin. The supported versions are:

By default Nev will use reduced. full currently logs to stdout so is not recommend when running Nev in the terminal version.

// settings.json
{
    "plugin.my_plugin.permissions": {
        "wasi": "none", // or "reduced" (default) or "full"
    }
}