UNPKG

codemirror-languageservice

Version:

Integrate a Language Server Protocol compatible language service into CodeMirror

57 lines 1.89 kB
import { type LintSource } from '@codemirror/lint'; import { type Diagnostic } from 'vscode-languageserver-protocol'; import { type TextDocument } from 'vscode-languageserver-textdocument'; import { type LSPResult } from './types.js'; export declare namespace createLintSource { interface Options { /** * Provide LSP diagnostics. * * @param textDocument * The text document for which to provide diagnostics. * @returns * An array of LSP diagnostics. */ doDiagnostics: (textDocument: TextDocument) => LSPResult<Iterable<Diagnostic>>; /** * Format the source of a diagnostic. * * @param diagnostic * The diagnostic for which to format the source. * @returns * The formatted source */ formatSource?: (diagnostic: Diagnostic) => string | undefined; /** * An additional class for all diagnostics provided by this validation. */ markClass?: string; } } /** * Create an LSP based lint source. * * By default CodeMirror provides styling for the `cm-lintRange-hint`, `cm-lintRange-info`, * `cm-lintRange-warning`, and `cm-lintRange-error` classes. This extension also uses the * `cm-lintRange-deprecated` and `cm-lintRange-unnecessary` classes which you may want to style. For * example: * * ```css *.cm-lintRange-deprecated { * background-image: none !important; * text-decoration: line-through; * } * * .cm-lintRange-unnecessary { * background-repeat: no-repeat !important; * opacity: 0.4; * } * ``` * * @param options * Options to configure the linting. * @returns * A CodeMirror lint source that uses LSP based diagnostics. */ export declare function createLintSource(options: createLintSource.Options): LintSource; //# sourceMappingURL=lint.d.ts.map