Skip to content

LspClient

Source: src/services/lsp.ts

LspClient(transport: Leap0Transport)

Starts and interacts with language servers inside a sandbox.

  • Leap0Error: If an API call fails.
  • Error: If the service returns an unexpected empty response.
async start(sandbox: SandboxRef, languageId: string, pathToProject: string, options?: RequestOptions): Promise<LspResponse>

Starts a language server for a project path inside the sandbox.

  • 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.
  • The language server response payload.
async stop(sandbox: SandboxRef, languageId: string, pathToProject: string, options?: RequestOptions): Promise<LspResponse>

Stops a previously started language server.

  • 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.
  • The language server response payload.
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.

  • 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.
await sandbox.lsp.didOpen(
"typescript",
"/workspace/app",
"file:///workspace/app/src/index.ts",
"const x = 1;",
1,
);
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.

  • 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.
async didClose(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, options?: RequestOptions): Promise<void>

Closes a previously opened document.

  • 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.
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.

  • 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.
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.

  • 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.
  • The raw JSON-RPC response from the language server.
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.

  • 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.
  • The raw JSON-RPC response from the language server.
async documentSymbols(sandbox: SandboxRef, languageId: string, pathToProject: string, uri: string, options?: RequestOptions): Promise<LspJsonRpcResponse>

Returns document symbols for an open document.

  • 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.
  • The raw JSON-RPC response from the language server.
async documentSymbolsPath(sandbox: SandboxRef, languageId: string, pathToProject: string, path: string, options?: RequestOptions): Promise<LspJsonRpcResponse>

Returns document symbols for a filesystem path.

  • 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.
  • The raw JSON-RPC response from the language server.