UNPKG

@jupyter-lsp/jupyterlab-lsp

Version:

Language Server Protocol integration for JupyterLab

101 lines (100 loc) 3.85 kB
import { JupyterFrontEnd } from '@jupyterlab/application'; import { VDomModel, VDomRenderer } from '@jupyterlab/apputils'; import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; import { ILSPConnection, ILSPDocumentConnectionManager, VirtualDocument, WidgetLSPAdapter, ILanguageServerManager } from '@jupyterlab/lsp'; import { INotebookModel, NotebookPanel } from '@jupyterlab/notebook'; import { Popup } from '@jupyterlab/statusbar'; import { TranslationBundle } from '@jupyterlab/translation'; import { LabIcon } from '@jupyterlab/ui-components'; import React from 'react'; import '../../style/statusbar.css'; import * as SCHEMA from '../_schema'; import { TSessionMap } from '../tokens'; export interface IListProps { /** * A title to display. */ title: string; list: any[]; /** * By default the list will be expanded; to change the initial state to collapsed, set to true. */ startCollapsed?: boolean; } export interface ICollapsibleListStates { isCollapsed: boolean; } /** * StatusBar item. */ export declare class LSPStatus extends VDomRenderer<LSPStatus.Model> { protected displayText: boolean; protected _popup: Popup | null; private trans; /** * Construct a new VDomRenderer for the status item. */ constructor(displayText: boolean, shell: JupyterFrontEnd.IShell, trans: TranslationBundle); /** * Render the status item. */ render(): React.JSX.Element | null; handleClick: () => void; } export declare class StatusButtonExtension implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> { private options; constructor(options: { languageServerManager: ILanguageServerManager; connectionManager: ILSPDocumentConnectionManager; shell: JupyterFrontEnd.IShell; translatorBundle: TranslationBundle; }); /** * For statusbar registration and for internal use. */ createItem(displayText?: boolean): LSPStatus; /** * For registration on notebook panels. */ createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): LSPStatus; } type StatusCode = 'noServerExtension' | 'waiting' | 'initializing' | 'initialized' | 'connecting' | 'initializedButSomeMissing'; export interface IStatus { connectedDocuments: Set<VirtualDocument>; initializedDocuments: Set<VirtualDocument>; openConnections: Array<ILSPConnection>; detectedDocuments: Set<VirtualDocument>; status: StatusCode; } export declare namespace LSPStatus { /** * A VDomModel for the LSP of current file editor/notebook. */ class Model extends VDomModel { private _shell; languageServerManager: ILanguageServerManager; trans: TranslationBundle; private _connectionManager; private _shortMessageByStatus; constructor(_shell: JupyterFrontEnd.IShell, trans: TranslationBundle); get availableServers(): TSessionMap; get supportedLanguages(): Set<string>; private _isServerRunning; get documentsByServer(): Map<SCHEMA.LanguageServerSession, Map<string, VirtualDocument[]>>; get serversAvailableNotInUse(): Array<SCHEMA.LanguageServerSession>; get detectedLanguages(): Set<string>; get missingLanguages(): Array<string>; get status(): IStatus; get statusIcon(): LabIcon; get shortMessage(): string; get longMessage(): string; get adapter(): WidgetLSPAdapter<IDocumentWidget> | null; get connectionManager(): ILSPDocumentConnectionManager; /** * Note: it is ever only set once, as connectionManager is a singleton. */ set connectionManager(connectionManager: ILSPDocumentConnectionManager); private _onChange; } } export {};