LspClient
Source: src/services/lsp.ts
Signature
Section titled “Signature”LspClient(transport: Leap0Transport)Overview
Section titled “Overview”Starts and interacts with language servers inside a sandbox.
Throws
Section titled “Throws”Leap0Error: If an API call fails.Error: If the service returns an unexpected empty response.
Methods
Section titled “Methods”async start(sandbox: SandboxRef, languageId: string, pathToProject: string, options?: RequestOptions): Promise<LspResponse>Starts a language server for a project path inside the sandbox.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The language server response payload.
async stop(sandbox: SandboxRef, languageId: string, pathToProject: string, options?: RequestOptions): Promise<LspResponse>Stops a previously started language server.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The language server response payload.
didOpen
Section titled “didOpen”async didOpen(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, textOrOptions?: string | RequestOptions, versionOrOptions?: number | RequestOptions, options?: RequestOptions): Promise<void>Opens a document in the language server.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.uri: File URI to open.textOrOptions: Optional in-memory document text, or request options when opening from disk.versionOrOptions: Optional document version, or request options when no explicit version is needed.options: Optional request options.
Examples
Section titled “Examples”await sandbox.lsp.didOpen( "typescript", "/workspace/app", "file:///workspace/app/src/index.ts", "const x = 1;", 1,);didOpenPath
Section titled “didOpenPath”async didOpenPath(sandbox: SandboxRef, languageId: string, pathToProject: string, path: string, textOrOptions?: string | RequestOptions, versionOrOptions?: number | RequestOptions, options?: RequestOptions): Promise<void>Opens a document by filesystem path instead of a file URI.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.path: Filesystem path to open.textOrOptions: Optional in-memory document text, or request options when opening from disk.versionOrOptions: Optional document version, or request options when no explicit version is needed.options: Optional request options.
didClose
Section titled “didClose”async didClose(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, options?: RequestOptions): Promise<void>Closes a previously opened document.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.uri: File URI to close.options: Optional request settings such as timeout and query params.
didClosePath
Section titled “didClosePath”async didClosePath(sandbox: SandboxRef, languageId: string, pathToProject: string, path: string, options?: RequestOptions): Promise<void>Closes a document by filesystem path instead of a file URI.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.path: Filesystem path to close.options: Optional request settings such as timeout and query params.
completions
Section titled “completions”async completions(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, line: number, character: number, options?: RequestOptions): Promise<LspJsonRpcResponse>Requests completion items at a line/character position.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.uri: File URI to inspect.line: Zero-based line number.character: Zero-based character offset.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The raw JSON-RPC response from the language server.
completionsPath
Section titled “completionsPath”async completionsPath(sandbox: SandboxRef, languageId: string, pathToProject: string, path: string, line: number, character: number, options?: RequestOptions): Promise<LspJsonRpcResponse>Requests completion items for a filesystem path.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.path: Filesystem path to inspect.line: Zero-based line number.character: Zero-based character offset.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The raw JSON-RPC response from the language server.
documentSymbols
Section titled “documentSymbols”async documentSymbols(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, options?: RequestOptions): Promise<LspJsonRpcResponse>Returns document symbols for an open document.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.uri: File URI to inspect.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The raw JSON-RPC response from the language server.
documentSymbolsPath
Section titled “documentSymbolsPath”async documentSymbolsPath(sandbox: SandboxRef, languageId: string, pathToProject: string, path: string, options?: RequestOptions): Promise<LspJsonRpcResponse>Returns document symbols for a filesystem path.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.languageId: Language server identifier.pathToProject: Project path inside the sandbox.path: Filesystem path to inspect.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The raw JSON-RPC response from the language server.