UNPKG

codemirror-languageservice

Version:

Integrate a Language Server Protocol compatible language service into CodeMirror

49 lines 2.02 kB
import { type CompletionSource } from '@codemirror/autocomplete'; import { type CompletionContext, type CompletionItem, type CompletionItemKind, type CompletionList, type Position } from 'vscode-languageserver-protocol'; import { type TextDocument } from 'vscode-languageserver-textdocument'; import { fromMarkupContent } from './markup-content.js'; import { type LSPResult } from './types.js'; export declare namespace createCompletionSource { interface Options extends fromMarkupContent.Options { /** * Convert an LSP completion item kind to a CodeMirror completion type. * * @param kind * The LSP completion item kind to convert * @returns * The CodeMirror completion type. */ fromCompletionItemKind?: (kind: CompletionItemKind | undefined) => string | undefined; /** * Provide LSP completions items. * * @param textDocument * The text document for which to provide completion items. * @param position * The position for which to provide completion items. * @param context * The completion context. * @returns * A completion list, or just the items as an iterable. */ doComplete: (textDocument: TextDocument, position: Position, context: CompletionContext) => LSPResult<CompletionList | Iterable<CompletionItem>>; /** * The section to use for completions. */ section?: string; /** * Only trigger completions automatically when one of these characters is typed. */ triggerCharacters?: string; } } /** * Create an LSP based completion source. * * @param options * Options to configure the completion. * @returns * A CodeMirror completion source that uses LSP based completions. */ export declare function createCompletionSource(options: createCompletionSource.Options): CompletionSource; //# sourceMappingURL=completion.d.ts.map