A language server for Wren. Releases


Editors

VS Code
Install from the Visual Studio Marketplace.
Neovim
See setup instructions in the README.
Sublime Text
Install LSP-wren-lsp from Package Control.

Configuration

Place a wren-lsp.json in your project root. The server searches upward from each opened file to find it.

{
  "version": 1,
  "extends": ["~/.config/wren-lsp/base.json"],
  "modules": [
    "./src",
    "./lib",
    { "game": "./src/game.wren" }
  ],
  "resolvers": [
    { "type": "path", "roots": ["./src"], "delimiter": "/" },
    { "type": "plugin", "library": "./resolver" }
  ],
  "diagnostics": {
    "missing_import": "warning",
    "extension_in_import": "info",
    "unknown_variable": "error"
  }
}

version

Schema version. Currently 1.

extends

Paths to parent configs. Later entries override earlier ones.

modules

Where to find Wren files. Each entry is either:

resolvers

How imports are resolved. Tried in order until one matches.

path
Treats imports as file paths. Options: roots, delimiter.
{
  "type": "path",
  "roots": ["./src", "./lib"],
  "extensions": [".wren"],
  "indexFiles": ["mod.wren", "init.wren"]
}
plugin
Loads a shared library for custom resolution. See Plugins.
{
  "type": "plugin",
  "library": "./my-resolver"
}

diagnostics

Severity for each diagnostic. Values: error, warning, info, hint, none.

missing_import
Import could not be resolved. Default: warning.
extension_in_import
Import includes .wren extension. Default: info.
unknown_variable
Variable not found in scope. Default: error.

Plugins

Plugins are shared libraries that resolve imports using custom logic. Useful for game engines or frameworks with their own module systems.

The library path should omit the extension—it is added automatically (.so, .dylib, .dll).

C Interface

Your library must export two functions with C linkage:

typedef struct {
    const char* severity;  // "error", "warning", "info", "hint"
    const char* message;
} WrenLspDiagnostic;

typedef struct {
    const char* canonical_id;  // required if resolved
    const char* uri;           // file:// URI or null
    const char* source;        // virtual source or null
    const char* kind;          // "file", "virtual", or "remote"
    WrenLspDiagnostic* diagnostics;
    size_t diagnostics_len;
} WrenLspResolveResult;

WrenLspResolveResult wren_lsp_resolve_module(
    const char* importer_uri,
    const char* import_string,
    const char* project_root
);

void wren_lsp_free_result(WrenLspResolveResult result);

Parameters

importer_uri
File URI of the importing file.
import_string
The import string to resolve.
project_root
Absolute path to the project root.

Return Value

Set canonical_id to the resolved module identifier. Return null to indicate the import could not be resolved.

Set kind to "file" and uri to the file path.

The LSP calls wren_lsp_free_result after processing, so you can free any memory allocated for the result.