@jupyter-lsp/jupyterlab-lsp
Version:
Language Server Protocol integration for JupyterLab
66 lines (65 loc) • 2.19 kB
TypeScript
import { CodeEditor } from '@jupyterlab/codeeditor';
import { IDocumentWidget } from '@jupyterlab/docregistry';
import { IEditorPosition, WidgetLSPAdapter } from '@jupyterlab/lsp';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import { Tooltip } from '@jupyterlab/tooltip';
import * as lsProtocol from 'vscode-languageserver-protocol';
interface IFreeTooltipOptions extends Tooltip.IOptions {
/**
* Position at which the tooltip should be placed, or null (default) to use the current cursor position.
*/
position: CodeEditor.IPosition | undefined;
/**
* HoverBox privilege.
*/
privilege?: 'above' | 'below' | 'forceAbove' | 'forceBelow';
/**
* Alignment with respect to the current token.
*/
alignment?: 'start' | 'end' | undefined;
/**
* default: true; ESC will always hide
*/
hideOnKeyPress?: boolean;
}
type Bundle = {
'text/plain': string;
} | {
'text/markdown': string;
};
/**
* Tooltip which can be placed at any character, not only at the current position (derived from getCursorPosition)
*/
export declare class FreeTooltip extends Tooltip {
protected options: IFreeTooltipOptions;
constructor(options: IFreeTooltipOptions);
setBundle(bundle: Bundle): void;
handleEvent(event: Event): void;
private _setGeometry;
setPosition(position: CodeEditor.IPosition): void;
}
export declare namespace EditorTooltip {
interface IOptions {
id?: string;
markup: lsProtocol.MarkupContent;
ceEditor: CodeEditor.IEditor;
position: IEditorPosition;
adapter: WidgetLSPAdapter<IDocumentWidget>;
className?: string;
tooltip?: Partial<IFreeTooltipOptions>;
}
}
export declare class EditorTooltipManager {
private rendermimeRegistry;
private currentTooltip;
private currentOptions;
constructor(rendermimeRegistry: IRenderMimeRegistry);
create(options: EditorTooltip.IOptions): FreeTooltip;
showOrCreate(options: EditorTooltip.IOptions): FreeTooltip;
get position(): IEditorPosition;
isShown(id?: string): boolean;
hide(): void;
show(): void;
remove(): void;
}
export {};