Taplo

Most features of the Visual Studio Code extension is powered by a language server that conforms with the Language Server Protocol 3.16.

The language server is also intended for public use for integration with other environments.

#Usage

#Native Binary

The language server is available on crates.io, running cargo install taplo-lsp will install the server as a taplo-lsp command line application, this can be used with TCP or standard i/o.

#JavaScript Package

The server is also available on NPM, opposed to the native binary, this is only a helper library which you can embed in your application.

It exposes an interface for the handlers it needs in order to communicate with the outside world, an example usage is here.

It also needs fetch to be available, if run inside NodeJS, node-fetch and some hacks are required:

import fetch, { Headers, Request, Response } from "node-fetch";
global.Headers = Headers;
global.Request = Request;
global.Response = Response;
global.Window = Object;
global.fetch = fetch;

In theory, the server with a subset of the features should be able to be used inside any browser with WebAssembly support, but it is untested.

#Additional Info

The server uses the evenBetterToml section for fetching configurations, as this is the extension's name in VSCode.

#Additional LSP Methods

Taplo also supports additional methods that are not in the official LSP specification:

/**
* Sent from the client to the server.
*
* Convert a TOML text to JSON.
*/
export namespace TomlToJson {
export interface Params {
/**
* TOML text
*/
text: string;
}
export interface Response {
/**
* JSON text
*/
text?: string;
errors?: string[];
}
export const METHOD = "taplo/tomlToJson";
}
/**
* Sent from the client to the server.
*
* Convert a JSON text to TOML.
*/
export namespace JsonToToml {
export interface Params {
/**
* JSON text
*/
text: string;
}
export interface Response {
/**
* TOML text
*/
text?: string;
error?: string;
}
export const METHOD = "taplo/jsonToToml";
}
/**
* Sent from the client to the server.
*
* Print the syntax tree for a document for debugging.
*/
export namespace SyntaxTree {
export interface Params {
/**
* URI of the TOML document,
* it must have been opened.
*/
uri: string;
}
export interface Response {
/**
* The syntax tree.
*/
text: string;
}
export const METHOD = "taplo/syntaxTree";
}
/**
* Sent from the server to the client.
*
* Used for showing a message to the user with
* a button that navigates to the server's logs.
*/
export namespace MessageWithOutput {
export const enum MessageKind {
Info = "info",
Warn = "warn",
Error = "error",
}
export interface Params {
kind: MessageKind;
message: string;
}
export const METHOD = "taplo/messageWithOutput";
}
/**
* Sent from the client to the server.
*
* Set the path the server should use for caching,
* this is optional.
*/
export namespace CachePath {
export interface Params {
path: string;
}
export const METHOD = "taplo/cachePath";
}