UNPKG

codemirror-languageservice

Version:

Integrate a Language Server Protocol compatible language service into CodeMirror

42 lines 1.41 kB
import { type EditorState, type Extension } from '@codemirror/state'; import { TextDocument } from 'vscode-languageserver-textdocument'; /** * Assign a {@link TextDocument} to an editor state. * * This text document is used by other extensions provided by `codemirror-languageservice`. * * The language ID is determined from the name of the * [language](https://codemirror.net/#languages) used. If this isn’t found, the language ID defaults * to `plaintext`. * * @param uri * The URI to use for the text document. If this is left unspecified, an auto-incremented * `inmemory://` URI is used. * @returns * A CodeMirror {@link Extension}. * @example * ```ts * import { json } from '@codemirror/lang-json' * import { EditorState } from '@codemirror/state' * import { textDocument } from 'codemirror-languageservice' * * const state = EditorState.create({ * doc: 'console.log("Hello world!")\n', * extensions: [ * json(), * textDocument('file:///example.js') * ] * }) * ``` */ export declare function textDocument(uri?: string): Extension; /** * Get the {@link TextDocument} for a CodeMirror {@link EditorState}. * * @param state * The editor state to get the text document for. * @returns * The text document. */ export declare function getTextDocument(state: EditorState): TextDocument; //# sourceMappingURL=text-document.d.ts.map