LspClient
Source: leap0/_sync/lsp.py
Signature
Section titled “Signature”LspClient(transport: Transport)Overview
Section titled “Overview”Start and interact with language servers for code intelligence inside a sandbox.
Supported languages: Python (pyright) and TypeScript/JavaScript (typescript-language-server).
The typical flow is start -> did_open -> completions or
document_symbols -> did_close -> stop.
Attributes: None.
Methods
Section titled “Methods”start(sandbox: SandboxRef, *, language_id: str, path_to_project: str) -> LspResponseStart the LSP server for a language and project.
Spawns the server process and sends the LSP initialize handshake
automatically.
Args:
sandbox: Sandbox ID or object.
language_id: Language identifier ("python", "typescript", or "javascript").
path_to_project: Project directory path inside the sandbox.
Returns: LspResponse: Server startup result.
stop(sandbox: SandboxRef, *, language_id: str, path_to_project: str) -> LspResponseSend shutdown and exit to the language server and terminate it.
Args: sandbox: Sandbox ID or object. language_id: Language identifier for the LSP operation. path_to_project: Project path inside the sandbox.
Returns: object: Result returned by this operation.
did_open
Section titled “did_open”did_open(sandbox: SandboxRef, *, language_id: str, path_to_project: str, uri: str, text: str | None = None, version: int = 1, http_timeout: float | None = None) -> NoneNotify the language server that a document was opened.
Must be called before requesting completions or symbols.
Args: sandbox: Sandbox ID or object. language_id: Language identifier for the LSP operation. path_to_project: Project path inside the sandbox. uri: Document URI. text: Parameter for this operation. version: Parameter for this operation. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
did_open_path
Section titled “did_open_path”did_open_path(sandbox: SandboxRef, *, language_id: str, path_to_project: str, path: str, text: str | None = None, version: int = 1, http_timeout: float | None = None) -> NoneLike :meth:did_open but accepts a file path instead of a URI.
Args: sandbox: Sandbox ID or object. language_id: Language identifier for the LSP operation. path_to_project: Project path inside the sandbox. path: File path inside the sandbox. text: Optional full document text to send with the open notification. version: Document version number. http_timeout: Optional HTTP request timeout in seconds for this SDK call.
did_close
Section titled “did_close”did_close(sandbox: SandboxRef, *, language_id: str, path_to_project: str, uri: str, http_timeout: float | None = None) -> NoneNotify the language server that a document was closed.
Args: sandbox: Sandbox ID or object. language_id: Language identifier for the LSP operation. path_to_project: Project path inside the sandbox. uri: Document URI.
did_close_path
Section titled “did_close_path”did_close_path(sandbox: SandboxRef, *, language_id: str, path_to_project: str, path: str, http_timeout: float | None = None) -> NoneLike :meth:did_close but accepts a file path instead of a URI.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
completions
Section titled “completions”completions(sandbox: SandboxRef, *, language_id: str, path_to_project: str, uri: str, line: int, character: int, http_timeout: float | None = None) -> LspJsonRpcResponseRequest completions from the language server.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: LspJsonRpcResponse: Raw JSON-RPC response payload.
completions_path
Section titled “completions_path”completions_path(sandbox: SandboxRef, *, language_id: str, path_to_project: str, path: str, line: int, character: int, http_timeout: float | None = None) -> LspJsonRpcResponseLike :meth:completions but accepts a file path instead of a URI.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.
document_symbols
Section titled “document_symbols”document_symbols(sandbox: SandboxRef, *, language_id: str, path_to_project: str, uri: str, http_timeout: float | None = None) -> LspJsonRpcResponseRequest document symbols from the language server.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: LspJsonRpcResponse: Raw JSON-RPC response payload.
document_symbols_path
Section titled “document_symbols_path”document_symbols_path(sandbox: SandboxRef, *, language_id: str, path_to_project: str, path: str, http_timeout: float | None = None) -> LspJsonRpcResponseLike :meth:document_symbols but accepts a file path instead of a URI.
Args: http_timeout: Optional HTTP request timeout in seconds for this SDK call.
Returns: object: Result returned by this operation.