@krassowski/jupyterlab-lsp
Version:
Language Server Protocol integration for JupyterLab
110 lines (109 loc) • 4.84 kB
TypeScript
import { CodeEditor } from '@jupyterlab/codeeditor';
import { CompletionConnector, CompletionHandler, ContextConnector } from '@jupyterlab/completer';
import { Session } from '@jupyterlab/services';
import { LabIcon } from '@jupyterlab/ui-components';
import { ILSPCompletionThemeManager } from '@krassowski/completion-theme/lib/types';
import type * as lsProtocol from 'vscode-languageserver-types';
import { CodeCompletion as LSPCompletionSettings } from '../../_completion';
import { LSPConnection } from '../../connection';
import { FeatureSettings } from '../../feature';
import { ExtendedCompletionTriggerKind } from '../../lsp';
import { IRootPosition, IVirtualPosition } from '../../positioning';
import { ILSPLogConsole } from '../../tokens';
import { VirtualDocument } from '../../virtual/document';
import { IVirtualEditor } from '../../virtual/editor';
import { CompletionLabIntegration } from './completion';
import { ICompletionsSource, IExtendedCompletionItem } from './item';
/**
* Completion items reply from a specific source
*/
export interface ICompletionsReply extends CompletionHandler.ICompletionItemsReply {
source: ICompletionsSource | null;
items: IExtendedCompletionItem[];
}
export declare function transformLSPCompletions<T>(token: CodeEditor.IToken, position_in_token: number, lspCompletionItems: lsProtocol.CompletionItem[], createCompletionItem: (kind: string, match: lsProtocol.CompletionItem) => T, console: ILSPLogConsole): {
start: number;
end: number;
items: T[];
source: {
name: string;
priority: number;
};
};
/**
* A LSP connector for completion handlers.
*/
export declare class LSPConnector implements CompletionHandler.ICompletionItemsConnector {
protected options: LSPConnector.IOptions;
isDisposed: boolean;
private _editor;
private _connections;
private _context_connector;
private _kernel_connector;
private _kernel_and_context_connector;
private console;
responseType: "ICompletionItemsReply";
virtual_editor: IVirtualEditor<CodeEditor.IEditor>;
trigger_kind: ExtendedCompletionTriggerKind;
lab_integration: CompletionLabIntegration;
items: CompletionHandler.ICompletionItems;
get kernel_completions_first(): boolean;
protected get use_lsp_completions(): boolean;
protected get use_kernel_completions(): boolean;
protected get suppress_continuous_hinting_in(): string[];
protected get suppress_trigger_character_in(): string[];
get should_show_documentation(): boolean;
/**
* Create a new LSP connector for completion requests.
*
* @param options - The instantiation options for the LSP connector.
*/
constructor(options: LSPConnector.IOptions);
dispose(): void;
protected get _has_kernel(): boolean;
protected get _is_kernel_idle(): boolean;
protected get _should_wait_for_busy_kernel(): boolean;
protected _kernel_language(): Promise<string>;
protected get _kernel_timeout(): number;
get fallback_connector(): ContextConnector | CompletionConnector;
protected transform_from_editor_to_root(position: CodeEditor.IPosition): IRootPosition;
/**
* Fetch completion requests.
*
* @param request - The completion request text and details.
*/
fetch(request: CompletionHandler.IRequest): Promise<CompletionHandler.ICompletionItemsReply | undefined>;
get_connection(uri: string): LSPConnection | undefined;
fetch_lsp(token: CodeEditor.IToken, typed_character: string, start: IVirtualPosition, end: IVirtualPosition, cursor: IVirtualPosition, document: VirtualDocument, position_in_token: number): Promise<ICompletionsReply>;
protected icon_for(type: string): LabIcon;
private transform_reply;
protected merge_replies(replies: ICompletionsReply[], editor: CodeEditor.IEditor): ICompletionsReply;
list(query: string | undefined): Promise<any>;
remove(id: CompletionHandler.IRequest): Promise<any>;
save(id: CompletionHandler.IRequest, value: void): Promise<any>;
private suppress_if_needed;
}
/**
* A namespace for LSP connector statics.
*/
export declare namespace LSPConnector {
/**
* The instantiation options for cell completion handlers.
*/
interface IOptions {
/**
* The editor used by the LSP connector.
*/
editor: CodeEditor.IEditor;
virtual_editor: IVirtualEditor<CodeEditor.IEditor>;
/**
* The connections to be used by the LSP connector.
*/
connections: Map<VirtualDocument.id_path, LSPConnection>;
settings: FeatureSettings<LSPCompletionSettings>;
labIntegration: CompletionLabIntegration;
themeManager: ILSPCompletionThemeManager;
session?: Session.ISessionConnection | null;
console: ILSPLogConsole;
}
}