import { EventEmitter } from "events"; declare enum LSPClientState { STOPPED = "stopped", STARTING = "starting", RUNNING = "running", STOPPING = "stopping" } /** * Internal configuration for LSP client * This interface defines the required structure for the LSP client configuration */ interface LSPConfig { timeout: number; enableFileWatcher: boolean; logLevel: string; /** * Map of language IDs to command arrays * First element is the executable path (can be relative or absolute) * Remaining elements are command arguments */ lspCommands: Record; } /** * User-provided configuration to override default LSP settings * This allows users to specify custom paths for language servers * * @example * ```typescript * const customConfig: LSPUserConfig = { * timeout: 60000, * lspCommands: { * // Override typescript with absolute path to language server * typescript: ["/usr/local/bin/typescript-language-server", "--stdio"], * python: ["/path/to/custom/pyright-langserver", "--stdio"], * } * }; * const client = new LSPClient(rootUri, customConfig); * ``` */ export interface LSPUserConfig { timeout?: number; enableFileWatcher?: boolean; logLevel?: string; /** * Map of language IDs to command arrays * First element can be an absolute path to the language server executable */ lspCommands?: Record; } export declare const DEFAULT_CONFIG: LSPConfig; export declare const SymbolKind: { readonly File: 1; readonly Module: 2; readonly Namespace: 3; readonly Package: 4; readonly Class: 5; readonly Method: 6; readonly Property: 7; readonly Field: 8; readonly Constructor: 9; readonly Enum: 10; readonly Interface: 11; readonly Function: 12; readonly Variable: 13; readonly Constant: 14; readonly String: 15; readonly Number: 16; readonly Boolean: 17; readonly Array: 18; readonly Object: 19; readonly Key: 20; readonly Null: 21; readonly EnumMember: 22; readonly Struct: 23; readonly Event: 24; readonly Operator: 25; readonly TypeParameter: 26; }; export type SymbolKindType = (typeof SymbolKind)[keyof typeof SymbolKind]; export declare class LSPClient extends EventEmitter { private _rootUri; private _state; private _msgId; private _pending; private _proc; private _stdoutBuffer; private _openFiles; private _fileStates; private _fileVersions; private _shutdownSignal; private _tasks; private _config; /** * Creates a new LSP client instance * * @param _rootUri - The root URI of the project (file:// URI format) * @param userConfig - Optional user configuration to override defaults * - Can include custom absolute paths for language servers */ constructor(_rootUri: string, userConfig?: LSPUserConfig); get state(): LSPClientState; get isClosing(): boolean; start(lang: string): Promise; private _startSubprocess; private _initialize; private _setupMessageHandlers; private _handleData; private _handleMessage; private _handleDiagnostics; private _handleLogMessage; private _handleShowMessage; private _send; private _request; private _notify; private _manageFileState; readFile(uri: string): Promise; sendDidOpen(uri: string, content: string, languageId: string): Promise; sendDidChange(uri: string, content: string): Promise; sendDidClose(uri: string): Promise; sendReferences(uri: string, line: number, character: number, name?: string, timeout?: number): Promise; sendDefinition(uri: string, line: number, character: number): Promise; sendDocumentSymbol(uri: string, timeout?: number): Promise; streamRequests(method: (...args: any[]) => Promise, argsList: any[][], options?: { maxConcurrency?: number; showProgress?: boolean; progressEvery?: number; progressInterval?: number; }): Promise; shutdown(): Promise; private _cancelTasks; private _cleanup; getRelativePath(uri: string): string; sendHover(uri: string, position: { line: number; character: number; }, timeout?: number): Promise; /** * 对单个文件进行 LSP 诊断,返回 diagnostics 数组 */ diagnoseFile(uri: string, content: string, languageId: string, waitMs?: number): Promise; } export {};