UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

125 lines 3.73 kB
/** * LSP Manager * Manages multiple language server connections with auto-discovery and routing */ import { EventEmitter } from 'events'; import { LSPServerConfig } from './lsp-client.js'; import { CodeAction, CompletionItem, Diagnostic, FormattingOptions, TextEdit } from './protocol.js'; export interface LSPManagerConfig { /** Working directory / root URI for language servers */ rootUri?: string; /** Custom server configurations (overrides auto-discovery) */ servers?: LSPServerConfig[]; /** Enable auto-discovery of language servers */ autoDiscover?: boolean; /** Callback for initialization progress */ onProgress?: (result: LSPInitResult) => void; } export interface LSPInitResult { serverName: string; success: boolean; languages?: string[]; error?: string; } export interface DiagnosticsResult { uri: string; diagnostics: Diagnostic[]; } export declare class LSPManager extends EventEmitter { private clients; private languageToServer; private documentServers; private diagnosticsCache; private rootUri; private initialized; constructor(config?: LSPManagerConfig); /** * Initialize the LSP manager with auto-discovery and/or custom servers */ initialize(config?: LSPManagerConfig): Promise<LSPInitResult[]>; /** * Start a single language server */ private startServer; /** * Stop all language servers */ shutdown(): Promise<void>; /** * Get the client for a file based on its extension */ private getClientForFile; /** * Convert file path to URI */ private fileToUri; /** * Open a document in the appropriate language server */ openDocument(filePath: string, content?: string): Promise<boolean>; /** * Update a document in the language server */ updateDocument(filePath: string, content: string): boolean; /** * Close a document in the language server */ closeDocument(filePath: string): boolean; /** * Get diagnostics for a file */ getDiagnostics(filePath: string): Promise<Diagnostic[]>; /** * Get diagnostics for all open documents */ getAllDiagnostics(): DiagnosticsResult[]; /** * Get completions at a position in a file */ getCompletions(filePath: string, line: number, character: number): Promise<CompletionItem[]>; /** * Get code actions for a range in a file */ getCodeActions(filePath: string, startLine: number, startChar: number, endLine: number, endChar: number, diagnostics?: Diagnostic[]): Promise<CodeAction[]>; /** * Format a document */ formatDocument(filePath: string, options?: Partial<FormattingOptions>): Promise<TextEdit[]>; /** * Check if LSP is available for a file type */ hasLanguageSupport(filePath: string): boolean; /** * Get list of connected servers */ getConnectedServers(): string[]; /** * Get supported languages */ getSupportedLanguages(): string[]; /** * Check if manager is initialized */ isInitialized(): boolean; /** * Get server status */ getStatus(): { initialized: boolean; servers: Array<{ name: string; ready: boolean; languages: string[]; }>; }; } /** * Get or create the LSP manager singleton * Uses promise-based initialization to prevent race conditions */ export declare function getLSPManager(config?: LSPManagerConfig): Promise<LSPManager>; /** * Reset the LSP manager (for testing) */ export declare function resetLSPManager(): Promise<void>; //# sourceMappingURL=lsp-manager.d.ts.map