monaco-definition-provider - v2.0.0
    Preparing search index...

    Class DefinitionProvider

    Go-to-definition provider for Monaco Editor.

    • python resolves through a scope-aware tree-sitter analyzer.
    • typescript/javascript delegate to Monaco's built-in TypeScript language service, contributing only the lazy-file-loading fallback.
    • Other languages can be supported via registerAnalyzer.

    The host passes its own monaco namespace, which keeps the library free of a bundled monaco copy and the duplicate-instance hazard that comes with it.

    import * as monaco from 'monaco-editor';
    import { DefinitionProvider } from 'monaco-definition-provider';

    const provider = new DefinitionProvider(monaco, {
    loadFile: async (uri, importPath, fromUri) => {
    const content = await fetchFromServer(uri);
    return content === null ? null : { uri, content };
    }
    });
    provider.register('python');
    provider.register('typescript');
    Index

    Constructors

    Methods

    • Dispose all registrations, the workspace tracker, and analyzers.

      Returns void

    • Monaco DefinitionProvider implementation.

      Parameters

      Returns Promise<
          | {
              range: {
                  endColumn: number;
                  endLineNumber: number;
                  startColumn: number;
                  startLineNumber: number;
              };
              uri: unknown;
          }[]
          | null,
      >