@ym-han/monaco-error-lens
Version:
Error Lens for Monaco Editor, adapted from the VSCode Error Lens extension: makes diagnostics more visible with inline messages, line highlighting, and gutter icons. WARNING: Very experimental; use with caution.
146 lines • 4.06 kB
TypeScript
/**
* API for a specific editor instance with methods to manipulate decorations, get the current model, cursor position, etc.
*/
export interface MonacoEditor {
getModel(): MonacoEditorModel | null;
getPosition(): {
lineNumber: number;
column: number;
} | null;
deltaDecorations(oldDecorations: string[], newDecorations: MonacoDecoration[]): string[];
onDidChangeCursorPosition(listener: () => void): MonacoDisposable;
onDidChangeModel(listener: () => void): MonacoDisposable;
}
export interface MonacoEditorModel {
uri: {
toString(): string;
};
}
export interface MonacoRange {
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
}
export interface MonacoMarkerData {
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
message: string;
severity: number;
source?: string;
code?: string | number;
}
export interface MonacoDecoration {
range: MonacoRange;
options: MonacoDecorationOptions;
}
export interface MonacoDecorationOptions {
isWholeLine?: boolean;
className?: string;
glyphMarginClassName?: string;
after?: {
content: string;
inlineClassName: string;
};
hoverMessage?: {
value: string;
};
stickiness?: number;
}
export type MonacoMarkerSeverity = number;
export type MonacoDisposable = {
dispose(): void;
};
/**
* Monaco module namespace with static APIs that work across all editors and models
*/
export interface MonacoModule {
editor: {
getModelMarkers(options: {
resource: unknown;
}): MonacoMarkerData[];
onDidChangeMarkers(callback: (resources: {
toString(): string;
}[]) => void): MonacoDisposable;
};
}
/**
* Configuration options for Monaco Error Lens
*/
export interface ErrorLensOptions {
/** Enable inline diagnostic messages at the end of lines */
enableInlineMessages?: boolean;
/** Enable line background highlighting */
enableLineHighlights?: boolean;
/** Enable gutter icons for diagnostics */
enableGutterIcons?: boolean;
/** Template for formatting diagnostic messages */
messageTemplate?: string;
/** Control which lines to show diagnostics for */
followCursor?: 'allLines' | 'activeLine';
/** Maximum number of characters to show in inline messages */
maxMessageLength?: number;
/** Maximum number of markers to display per line */
maxMarkersPerLine?: number;
/** Filter which severity levels to show */
severityFilter?: number[];
/** Custom colors for different diagnostic severities */
colors?: Partial<ErrorLensColors>;
/** Delay in milliseconds before updating decorations */
updateDelay?: number;
/** Enable or disable the extension */
enabled?: boolean;
}
/**
* Color configuration for different diagnostic severities
*/
export interface ErrorLensColors {
error: {
background: string;
foreground: string;
};
warning: {
background: string;
foreground: string;
};
info: {
background: string;
foreground: string;
};
hint: {
background: string;
foreground: string;
};
}
/**
* Internal configuration state
*/
export type ErrorLensConfig = Required<ErrorLensOptions>;
/**
* Severity levels as constants
*/
export declare const SEVERITY_LEVELS: {
readonly ERROR: 8;
readonly WARNING: 4;
readonly INFO: 2;
readonly HINT: 1;
};
/**
* CSS class names used by Error Lens
*/
export declare const CSS_CLASSES: {
readonly MESSAGE: "monaco-error-lens-message";
readonly LINE: "monaco-error-lens-line";
readonly GUTTER: "monaco-error-lens-gutter";
readonly ERROR: "error";
readonly WARNING: "warning";
readonly INFO: "info";
readonly HINT: "hint";
};
/**
* Default configuration values
*/
export declare const DEFAULT_OPTIONS: Required<ErrorLensOptions>;
//# sourceMappingURL=types.d.ts.map