UNPKG

@nteract/monaco-editor

Version:

A React component for the monaco editor, tailored for nteract

79 lines (78 loc) 3.03 kB
import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; import { Channels } from "@nteract/messaging"; /** * Completion item provider. */ declare class CompletionItemProvider implements monaco.languages.CompletionItemProvider { private channels; private regexWhitespace; /** * Set Channels of Jupyter kernel. */ setChannels(channels: Channels | undefined): void; /** * Whether provider is connected to Jupyter kernel. */ get isConnectedToKernel(): boolean; /** * Additional characters to trigger completion other than Ctrl+Space. * We do not need any additional characters to trigger completion as the Monaco editor * by default triggers completion as the user types non-whitespace characters. */ get triggerCharacters(): never[]; /** * Get list of completion items at position of cursor. */ provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position): Promise<monaco.languages.CompletionList>; /** * Get list of completion items from Jupyter kernel. */ private codeCompleteObservable; /** * Converts Jupyter completion result to list of Monaco completion items. */ private adaptToMonacoCompletions; /** * Get magic prefix from text. */ private getMagicPrefix; /** * Whether all characters from cell start position up to current start position are whitespace. */ private isWhitespaceFromCellStart; /** * Converts Jupyter completion item kind to Monaco completion item kind. */ private adaptToMonacoCompletionItemKind; /** * Removes problematic prefixes based on the typed text. * * Instead of showing "some/path" we should only show "path". For paths with white space, the kernel returns * ""some/path with spaces"" which we want to change to ""path with spaces"". * * Additionally, typing "[]." should not suggest ".append" since this results in "[]..append". */ private sanitizeText; /** * Remove magics all % characters as Monaco doesn't like them for the filtering text. * Without this, completion won't show magics match items. * * Also remove quotes from the filter of a path wrapped in quotes to make sure we have * a smooth auto-complete experience. */ private getFilterText; /** * Get insertion text handling what to insert for the magics case depending on what * has already been typed. Also handles an edge case for file paths with "." in the name. */ private getInsertText; /** * Maps numbers to strings, such that if a>b numerically, f(a)>f(b) lexicograhically. * 1 -> "za", 26 -> "zz", 27 -> "zza", 28 -> "zzb", 52 -> "zzz", 53 ->"zzza" * @param order Number to be converted to a sorting-string. order >= 0. * @returns A string representing the order. */ private getSortText; } declare const completionProvider: CompletionItemProvider; export { completionProvider };