The `unist-util-lsp` library provides a focused set of utility functions to accurately convert positional information between unist (Universal Syntax Tree) nodes and the Language Server Protocol (LSP) format. This is crucial for developers building sophisticated tooling, such as IDE extensions or linters, that operate on both ASTs and interact with LSP-compliant language servers. The current stable version is 2.1.0, with an active release cadence demonstrating ongoing maintenance and feature additions. Key differentiators include its tight integration with the unist ecosystem and its precise mapping to LSP’s `Range` and `Position` types, making it an essential bridge for creating robust language-aware applications. It primarily targets environments supporting ECMAScript Modules (ESM) and requires Node.js version 16 or higher.
npm install unist-util-lspVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the core conversion utilities to map positional data between unist and LSP formats, including converting full positions and individual points, and showcasing the `fromPlace` utility.
Upgrade your Node.js environment to version 16 or higher. For example, use `nvm install 16 && nvm use 16`.
Migrate your project to use ES Modules `import` syntax. Ensure your `package.json` has `"type": "module"` or use `.mjs` file extensions.
Update your `@types/unist` package to the latest compatible version (e.g., `npm update @types/unist`).
Ensure you are using `unist-util-lsp` version 2.1.0 or newer if you intend to use the `fromPlace` function.
Change CommonJS `require()` calls to ES Module `import` statements: `import { fromPoint } from 'unist-util-lsp'`.Ensure the `place` argument passed to utilities like `fromPoint` or `fromPosition` is a valid `UnistPoint` or `UnistPosition` object, not nullish.
No dependency data recorded yet.