Skip to content
lsdocs plugin SDK API

lsdocs_plugin_sdk::testing #

Helpers for testing plugins without a host.

function context #

pub fn context(setup: &Setup) -> Context

A context for initialize whose events (logs, progress, notified diagnostics) are dropped.

function setup #

pub fn setup(plugin: &Plugin, params: InitializeParams) -> Setup

The setup plugin gets for params: its loader reads its settings from params.config. Panics if they cannot be read.

function context_with_parsers #

pub fn context_with_parsers(plugin: &Plugin, setup: &Setup, parsers: Vec<Plugin>) -> Context

A context for initialize whose host/parse requests go to parsers (the first taking the extension), with the syntax that plugin and the parsers declare, as the host would give them.

function run_transform #

pub async fn run_transform(
    plugin: &Plugin,
    setup: &Setup,
    documents: Vec<Document>,
) -> PluginResult<Vec<(Document, Vec<Diagnostic>)>>

Runs plugin's transformer over documents the way the host does: the collect pass over every document (if it collects), then the documents it generates, then the apply pass with everything collected, generated documents included. Returns each transformed document with the diagnostics its apply pass reported. Unlike the host, every document is passed, whatever node kinds it contains.

function run_transform_in #

pub async fn run_transform_in(
    plugin: &Plugin,
    ctx: &Context,
    documents: Vec<Document>,
) -> PluginResult<Vec<(Document, Vec<Diagnostic>)>>

run_transform with the context ctx (e.g. from context_with_parsers).