{"id":12282,"library":"unified-language-server","title":"Unified Language Server","description":"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.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/unifiedjs/unified-language-server","tags":["javascript","lsp","langserver","language server","unified","typescript"],"install":[{"cmd":"npm install unified-language-server","lang":"bash","label":"npm"},{"cmd":"yarn add unified-language-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add unified-language-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for processing multiple files with unified and handling configuration files.","package":"unified-engine","optional":false},{"reason":"Used internally since v4.0.0 for Language Server Protocol utilities related to unist ASTs.","package":"unist-util-lsp","optional":false},{"reason":"Commonly used as the default processor example; developers will typically depend on a specific unified processor.","package":"remark","optional":true}],"imports":[{"note":"Package is ESM-only since v3.0.0, requiring `import` syntax and a Node.js `type: \"module\"` package configuration.","wrong":"const { createUnifiedLanguageServer } = require('unified-language-server')","symbol":"createUnifiedLanguageServer","correct":"import { createUnifiedLanguageServer } from 'unified-language-server'"},{"note":"The `remark` package exports its processor as a named export, not a default export.","wrong":"import remark from 'remark'","symbol":"remark","correct":"import { remark } from 'remark'"},{"note":"TypeScript type import. Use `import type` to ensure it's not bundled as runtime code, especially if configuring a language server in TypeScript.","wrong":"import { LanguageServerOptions } from 'unified-language-server'","symbol":"LanguageServerOptions","correct":"import type { LanguageServerOptions } from 'unified-language-server'"}],"quickstart":{"code":"import { remark } from 'remark';\nimport { createUnifiedLanguageServer } from 'unified-language-server';\n\n// Set the process title for easier identification in system monitors\nprocess.title = 'my-remark-language-server';\n\n// Create and start the language server\ncreateUnifiedLanguageServer({\n  // Name of ignore files (e.g., '.remarkignore')\n  ignoreName: '.remarkignore',\n  // Field in package.json to look for configuration\n  packageField: 'remarkConfig',\n  // Prefix for plugin names (e.g., 'remark-lint-')\n  pluginPrefix: 'remark',\n  // Name of the RC file (e.g., '.remarkrc')\n  rcName: '.remarkrc',\n  // The package ID of the expected processor (e.g., 'remark')\n  processorName: 'remark',\n  // The specifier to get the processor on the resolved module (e.g., 'remark' for named export)\n  processorSpecifier: 'remark',\n  // Optional fallback processor if `processorName` isn't found locally\n  defaultProcessor: remark\n});\n\nconsole.log('Remark language server started. Waiting for client connection...');","lang":"javascript","description":"Demonstrates how to create a basic language server for `remark` using `unified-language-server`, including configuration options for file handling."},"warnings":[{"fix":"Upgrade your Node.js runtime to version 16.0 or newer.","message":"Support for Node.js 12 was removed. Ensure your environment runs Node.js 16.0 or higher.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update imports to use `import` statements and ensure your project is configured for ESM (e.g., `\"type\": \"module\"` in `package.json`).","message":"The package transitioned to ESM-only. CommonJS `require()` is no longer supported for importing `unified-language-server`.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Review existing configuration files (`.remarkrc`, etc.) to ensure compatibility with `unified-engine`'s updated YAML parser. Update YAML configurations if necessary.","message":"Updated `unified-engine` dependency, which notably introduced support for YAML 1.2 in configuration files. This might affect how existing configuration files are parsed if they rely on older YAML features or if new YAML 1.2 syntax is introduced.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"No direct fix needed for standard usage. If you have custom extensions interacting with internal structures, verify compatibility or consult the `unist-util-lsp` documentation.","message":"Refactored to use `unist-util-lsp` internally. While not a direct API change for most users, this signals significant internal architecture updates which could affect custom extensions or deep integrations.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Always ensure that the `processorName` specified (e.g., `remark`) is correctly listed and installed as a dependency in your language server's `package.json` or the user's project `node_modules`.","message":"If `options.processorName` cannot be found locally in `node_modules`, a warning is shown. This can happen if the processor (e.g., `remark`) is not installed as a dependency in the workspace where the language server is running.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const { createUnifiedLanguageServer } = require('unified-language-server');` to `import { createUnifiedLanguageServer } from 'unified-language-server';` and ensure `\"type\": \"module\"` is set in your `package.json`.","cause":"Attempting to `require()` an ESM-only package.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure the processor package (e.g., `remark`) is listed in your language server's `dependencies` and run `npm install`.","cause":"The specified `processorName` (e.g., 'remark') is not installed in the environment where the language server is executing.","error":"Error: Cannot find module 'remark' from '/path/to/language-server'"},{"fix":"Verify that `defaultProcessor` receives a valid `unified` processor instance (e.g., `remark`) and that its named export is correctly imported (e.g., `import { remark } from 'remark';`).","cause":"`defaultProcessor` was passed an incorrect value or the imported processor is not the expected `unified` function.","error":"TypeError: options.defaultProcessor is not a function"},{"fix":"Ensure both the `unified-language-server` package and the editor client integration are updated to their latest versions to support all configuration features.","cause":"Using an outdated client or language server definition that doesn't recognize newer configuration options.","error":"Language server failed to initialize: Configuration option 'requireConfig' is not recognized."}],"ecosystem":"npm"}