Unified Language Server

4.0.1 · active · verified Sun Apr 19

unified-language-server provides a framework for building language servers based on the unified ecosystem. It allows developers to create editor integrations that format and validate documents using existing unified processors like remark (for Markdown) or rehype (for HTML). The current stable version is 4.0.1, with minor releases typically focusing on dependency updates and bug fixes, and major versions introducing breaking changes such as Node.js version requirements or significant internal refactors (e.g., using `unist-util-lsp`). Key differentiators include its tight integration with `unified-engine` for configuration file support (like `.remarkrc`) and its ability to work with any unified processor, simplifying the creation of LSP-compliant tools for AST transformations. It supports features like document formatting, validation, and quick fixes.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to create a basic language server for `remark` using `unified-language-server`, including configuration options for file handling.

import { remark } from 'remark';
import { createUnifiedLanguageServer } from 'unified-language-server';

// Set the process title for easier identification in system monitors
process.title = 'my-remark-language-server';

// Create and start the language server
createUnifiedLanguageServer({
  // Name of ignore files (e.g., '.remarkignore')
  ignoreName: '.remarkignore',
  // Field in package.json to look for configuration
  packageField: 'remarkConfig',
  // Prefix for plugin names (e.g., 'remark-lint-')
  pluginPrefix: 'remark',
  // Name of the RC file (e.g., '.remarkrc')
  rcName: '.remarkrc',
  // The package ID of the expected processor (e.g., 'remark')
  processorName: 'remark',
  // The specifier to get the processor on the resolved module (e.g., 'remark' for named export)
  processorSpecifier: 'remark',
  // Optional fallback processor if `processorName` isn't found locally
  defaultProcessor: remark
});

console.log('Remark language server started. Waiting for client connection...');

view raw JSON →