@adecore/lsp
v0.22.1
Published
[](https://www.npmjs.com/package/@adecore/lsp) [](https://adecore.dev/lsp/)
Downloads
2,228
Readme
@adecore/lsp
A client for the Language Server Protocol 3.17, without a DOM and without Node or Bun APIs, so it runs in a backend, a utility process or a page. It also defines LanguageService, the interface @adecore/editor-react asks its features through. It starts no server: the app hands it a transport.
Install
bun add @adecore/lspUse
import { LspSession, createStreamTransport, pathToFileUri } from '@adecore/lsp';
const session = new LspSession(createStreamTransport(stream), { rootUri: pathToFileUri('/work') });
await session.initialize();
const document = session.openDocument({ uri: pathToFileUri('/work/example.ts'), languageId: 'typescript', text });
await document.updateText(nextText);
const hover = await document.hover({ line: 0, character: 6 });An answer for a text that changed in the meantime rejects with StaleResultError.
Entry points
| Import | What it holds |
|---|---|
| @adecore/lsp | LspSession, LspDocument, the transports, the edit and URI helpers, the Vue bridge and the protocol types |
| @adecore/lsp/testing | FakeLanguageServer and createMemoryTransportPair |
Documentation
| Page | What it covers | |---|---| | Sessions and transports | Stdio, WebSocket and memory transports, the handshake, capabilities and errors | | Documents and edits | Versions, requests, stale answers, edit helpers, workspace edits and renames | | Language service | The interface for editor features, and Vue with TypeScript | | Testing | A fake server in memory |
License
FSL-1.1-MIT
