Language servers
Diagnostics, definitions and references from a language server in the sandbox.
Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.
LanguageServers
Section titled “LanguageServers”LanguageServers answers questions about one file with a real language server in the sandbox. Each call starts the server, asks and stops it, so no idle server is left to reap.
Properties
Section titled “Properties”Python exposes these as methods; see below.
TypeScript exposes these as methods; see below.
| Property | Type | Description |
|---|---|---|
NoEgressProxy |
bool |
NoEgressProxy turns off the automatic proxy settings for Install (see EgressEnv). |
Ruby exposes these as methods; see below.
| Property | Type | Description |
|---|---|---|
SERVERS |
Map<String, Server> |
The default servers; a template that ships others passes its own command to query. |
useEgressProxy |
boolean |
Route installs through the sandbox’s layer-7 egress proxy while its rules are on (see egressEnv). |
completions()
Section titled “completions()”def completions(self, language: str, root: str, file: str, line: int, character: int, **options: Any) -> Any| Parameter | Type | Default |
|---|---|---|
language |
str |
|
root |
str |
|
file |
str |
|
line |
int |
|
character |
int |
|
options |
Any |
optional |
Returns Any
sdk/python/svm/lsp.py:125completions(language: string, root: string, file: string, line: number, character: number, options?: { server?: string[]; timeout?: number })| Parameter | Type | Default |
|---|---|---|
language |
string |
|
root |
string |
|
file |
string |
|
line |
number |
|
character |
number |
|
options |
{ server?: string[]; timeout?: number } |
optional |
Returns Promise<unknown>
sdk/typescript/src/lsp.ts:132func (l *LanguageServers) Completions(ctx context.Context, language, root, file string, line, character int) (json.RawMessage, error)| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
|
root |
string |
|
file |
string |
|
line |
int |
|
character |
int |
Returns (json.RawMessage, error)
sdk/go/guest_lsp.go:240def completions(language, root, file, line, character)| Parameter | Type | Default |
|---|---|---|
language |
||
root |
||
file |
||
line |
||
character |
sdk/ruby/lib/svm/language_servers.rb:86public Object completions(String language, String root, String file, int line, int character)| Parameter | Type | Default |
|---|---|---|
language |
String |
|
root |
String |
|
file |
String |
|
line |
int |
|
character |
int |
Returns Object
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:137constructor()
Section titled “constructor()”Not in the Python SDK’s LanguageServers.
constructor(private readonly sandbox: LspSandbox, private readonly options: { useEgressProxy?: boolean } = {})| Parameter | Type | Default |
|---|---|---|
sandbox |
LspSandbox |
|
options |
{ useEgressProxy?: boolean } |
{} |
sdk/typescript/src/lsp.ts:69Not in the Go SDK’s LanguageServers.
Not in the Ruby SDK’s LanguageServers.
Not in the Java SDK’s LanguageServers.
definitions()
Section titled “definitions()”def definitions(self, language: str, root: str, file: str, line: int, character: int, **options: Any) -> Any| Parameter | Type | Default |
|---|---|---|
language |
str |
|
root |
str |
|
file |
str |
|
line |
int |
|
character |
int |
|
options |
Any |
optional |
Returns Any
sdk/python/svm/lsp.py:128definitions(language: string, root: string, file: string, line: number, character: number, options?: { server?: string[]; timeout?: number })| Parameter | Type | Default |
|---|---|---|
language |
string |
|
root |
string |
|
file |
string |
|
line |
number |
|
character |
number |
|
options |
{ server?: string[]; timeout?: number } |
optional |
Returns Promise<unknown>
sdk/typescript/src/lsp.ts:135func (l *LanguageServers) Definitions(ctx context.Context, language, root, file string, line, character int) (json.RawMessage, error)| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
|
root |
string |
|
file |
string |
|
line |
int |
|
character |
int |
Returns (json.RawMessage, error)
sdk/go/guest_lsp.go:244def definitions(language, root, file, line, character)| Parameter | Type | Default |
|---|---|---|
language |
||
root |
||
file |
||
line |
||
character |
sdk/ruby/lib/svm/language_servers.rb:87public Object definitions(String language, String root, String file, int line, int character)| Parameter | Type | Default |
|---|---|---|
language |
String |
|
root |
String |
|
file |
String |
|
line |
int |
|
character |
int |
Returns Object
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:138diagnostics()
Section titled “diagnostics()”def diagnostics(self, language: str, root: str, file: str, **options: Any) -> list[dict[str, Any]]The file’s diagnostics once the server has settled: its last publish, so an empty set published while the project loads is not taken for the answer. Raises errors.TimeoutError (error_kind “timeout”) when the server published nothing for the file within the driver’s wait (8 s) instead of answering []; query gives the raw answer, whose complete is then false.
| Parameter | Type | Default |
|---|---|---|
language |
str |
|
root |
str |
|
file |
str |
|
options |
Any |
optional |
Returns list[dict[str, Any]]
Raises TimeoutError
sdk/python/svm/lsp.py:134async diagnostics(language: string, root: string, file: string, options?: { server?: string[]; timeout?: number }): Promise<unknown>The file’s diagnostics once the server has settled: its last publish, so an empty set published while the project loads is not taken for the answer. Throws TimeoutError (errorKind “timeout”) when the server published nothing for the file within the driver’s wait (8 s) instead of answering []; query gives the raw answer, whose complete is then false.
| Parameter | Type | Default |
|---|---|---|
language |
string |
|
root |
string |
|
file |
string |
|
options |
{ server?: string[]; timeout?: number } |
optional |
Returns Promise<unknown>
Raises TimeoutError
sdk/typescript/src/lsp.ts:146func (l *LanguageServers) Diagnostics(ctx context.Context, language, root, file string) (json.RawMessage, error)Diagnostics is the file’s diagnostics once the server has settled: its last publish, so an empty set published while the project loads is not taken for the answer. It returns a *TimeoutError (errors.Is(err, ErrTimeout), ErrorKind “timeout”) when the server published nothing for the file within the driver’s wait (8 s) instead of answering []; Query gives the raw answer, whose Complete is then false.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
|
root |
string |
|
file |
string |
Returns (json.RawMessage, error)
Raises ErrTimeout, TimeoutError
sdk/go/guest_lsp.go:255def diagnostics(language, root, file)The file’s diagnostics once the server has settled: its last publish, so an empty set published while the project loads is not taken for the answer. Raises TimeoutError (error_kind “timeout”) when the server published nothing for the file within the driver’s wait (8 s) instead of answering []; #query gives the raw answer, whose “complete” is then false.
| Parameter | Type | Default |
|---|---|---|
language |
||
root |
||
file |
Raises TimeoutError
sdk/ruby/lib/svm/language_servers.rb:93public Object diagnostics(String language, String root, String file)The file’s diagnostics once the server has settled: its last publish, so an empty set published while the project loads is not taken for the answer. Throws TimeoutException (error kind “timeout”) when the server published nothing for the file within the driver’s wait (8 s) instead of answering an empty list; query gives the raw answer, whose complete is then false.
| Parameter | Type | Default |
|---|---|---|
language |
String |
|
root |
String |
|
file |
String |
Returns Object
Raises TimeoutException
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:146egress_env()
Section titled “egress_env()”def egress_env(self) -> dict[str, str]The proxy settings the install needs while the sandbox’s layer-7 egress is on, else {}.
With the firewall on, nothing leaves the sandbox except through its proxy, which signs with the sandbox’s CA: pip, npm, go and curl need the proxy URL (credentials included) and the CA in the variables each reads. They are read from get_sandbox_egress at each install and passed as the command’s environment, never on its command line; the CA is written owner-only to ~/.svm/egress-ca.pem of the installing user (root). Without the firewall, or without permission to read it, the install runs as it always did.
Returns dict[str, str]
sdk/python/svm/lsp.py:61async egressEnv(): Promise<Record<string, string>>The proxy settings the install needs while the sandbox’s layer-7 egress is on, else {}. With the firewall on, nothing leaves the sandbox except through its proxy, which signs with the sandbox’s CA: pip, npm, go and curl need the proxy URL (credentials included) and the CA in the variables each reads. They are read from getSandboxEgress at each install and passed as the command’s environment, never on its command line; the CA is written owner-only to ~/.svm/egress-ca.pem of the installing user (root).
Returns Promise<Record<string, string>>
sdk/typescript/src/lsp.ts:77func (l *LanguageServers) EgressEnv(ctx context.Context) (map[string]string, error)EgressEnv is the proxy settings the install needs while the sandbox’s layer-7 egress is on, else nil. With the firewall on, nothing leaves the sandbox except through its proxy, which signs with the sandbox’s CA: pip, npm, go and curl need the proxy URL (credentials included) and the CA in the variables each reads. They are read at each install and travel as the command’s environment, never on its command line; the CA is written owner-only to ~/.svm/egress-ca.pem of the installing user (root). A box that cannot read the rules, a deployment without them or a key that may not read them gives the plain install, as before.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (map[string]string, error)
sdk/go/guest_lsp.go:120def egress_envThe proxy settings the install needs while the sandbox’s layer-7 egress is on, else {}. With the firewall on nothing leaves the sandbox except through its proxy, which signs with the sandbox’s CA: the proxy URL and the CA (written owner-only to ~/.svm/egress-ca.pem of root) go in the variables each installer reads, as the command’s environment.
Raises SandboxError
sdk/ruby/lib/svm/language_servers.rb:43public Map<String, String> egressEnv()The proxy settings an install needs while the sandbox’s layer-7 egress is on, else an empty map. With the firewall on nothing leaves the sandbox except through its proxy, which signs with the sandbox’s CA: pip, npm, go and curl need the proxy URL (credentials included) and the CA in the variables each reads. They are read at each install and passed as the command’s environment, never on its command line; the CA is written owner-only to ~/.svm/egress-ca.pem of the installing user (root). Without the firewall, or without permission to read it, the install runs as it always did.
Returns Map<String, String>
Raises SandboxException
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:63initialize()
Section titled “initialize()”Not in the Python SDK’s LanguageServers.
Not in the TypeScript SDK’s LanguageServers.
Not in the Go SDK’s LanguageServers.
def initialize(box, sandbox: nil, use_egress_proxy: true)sandbox (Sandbox#lsp passes it) is where #egress_env reads the egress settings; use_egress_proxy false never uses the proxy.
| Parameter | Type | Default |
|---|---|---|
box |
||
sandbox |
nil |
|
use_egress_proxy |
true |
sdk/ruby/lib/svm/language_servers.rb:36Not in the Java SDK’s LanguageServers.
install()
Section titled “install()”def install(self, language: str, *, timeout_seconds: int=600) -> NoneInstall the language server (and python3 for the driver) in the sandbox, as root.
Needs internet egress, or layer-7 egress rules that allow the package hosts (the install then goes through the sandbox’s proxy, see egress_env). It checks the free disk first and says so plainly when there is too little (MIN_FREE_MIB), instead of failing half way with ENOSPC.
| Parameter | Type | Default |
|---|---|---|
language |
str |
|
timeout_seconds |
int |
600 |
sdk/python/svm/lsp.py:89async install(language: string, timeoutSeconds = 600): Promise<void>Install the language server (and python3 for the driver) in the sandbox, as root. Needs internet egress, or layer-7 egress rules that allow the package hosts (the install then goes through the sandbox’s proxy, see egressEnv). It checks the free disk first and says so plainly when there is too little (LSP_MIN_FREE_MIB), instead of failing half way with ENOSPC.
| Parameter | Type | Default |
|---|---|---|
language |
string |
|
timeoutSeconds |
number |
600 |
sdk/typescript/src/lsp.ts:98func (l *LanguageServers) Install(ctx context.Context, language string) errorInstall installs the language server (and python3 for the driver) in the sandbox, as root. Needs internet egress, or layer-7 egress rules that allow the package hosts (the install then goes through the sandbox’s proxy, see EgressEnv). It checks the free disk first and says so plainly when there is too little (LSPMinFreeMiB), instead of failing half way with ENOSPC.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
Returns error
sdk/go/guest_lsp.go:153def install(language)Installs the language server (and python3 for the driver) in the sandbox, as root. Needs internet egress, or layer-7 egress rules that allow the package hosts (the install then goes through the sandbox’s proxy, see #egress_env).
| Parameter | Type | Default |
|---|---|---|
language |
Raises SandboxError
sdk/ruby/lib/svm/language_servers.rb:58public void install(String language)Installs the language server (and python3 for the driver) in the sandbox, as root. Needs internet egress, or egress rules that allow the package hosts (then through the proxy, see egressEnv).
| Parameter | Type | Default |
|---|---|---|
language |
String |
Raises SandboxException
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:88query()
Section titled “query()”def query(self, language: str, root: str, file: str, ops: list[dict[str, Any]], *, server: list[str] | None=None, timeout: int=60) -> list[dict[str, Any]]| Parameter | Type | Default |
|---|---|---|
language |
str |
|
root |
str |
|
file |
str |
|
ops |
list[dict[str, Any]] |
|
server |
list[str] | None |
None |
timeout |
int |
60 |
Returns list[dict[str, Any]]
sdk/python/svm/lsp.py:107async query(language: string, root: string, file: string, ops: LspOp[], options: { server?: string[]; timeout?: number } = {}): Promise<Array<{ op: string; result: unknown; complete?: boolean }>>The raw answers, one per op; a diagnostics answer carries complete: false when the server published nothing for the file in time.
| Parameter | Type | Default |
|---|---|---|
language |
string |
|
root |
string |
|
file |
string |
|
ops |
LspOp[] |
|
options |
{ server?: string[]; timeout?: number } |
{} |
Returns Promise<Array<{ op: string; result: unknown; complete?: boolean }>>
sdk/typescript/src/lsp.ts:113func (l *LanguageServers) Query(ctx context.Context, language, root, file string, ops []LSPOp, server []string, timeout int) ([]LSPAnswer, error)Query runs ops against file (relative to root). server overrides the default command; timeout is in seconds (0 means 60).
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
|
root |
string |
|
file |
string |
|
ops |
[]LSPOp |
|
server |
[]string |
|
timeout |
int |
Returns ([]LSPAnswer, error)
sdk/go/guest_lsp.go:183def query(language, root, file, ops, server: nil, timeout: 60)Runs ops (hashes like {op: “completion”, line: 0, character: 2}) against file (relative to root). server overrides the default command; timeout is in seconds.
| Parameter | Type | Default |
|---|---|---|
language |
||
root |
||
file |
||
ops |
||
server |
nil |
|
timeout |
60 |
Raises SandboxError
sdk/ruby/lib/svm/language_servers.rb:70public List<Map<String, Object>> query(String language, String root, String file, List<Map<String, Object>> ops, List<String> server, int timeoutSeconds)Runs ops against file (relative to root). server overrides the default command (null for the default); the timeout is in seconds (0 means 60). A diagnostics answer carries "complete": false when the server published nothing for the file in time.
| Parameter | Type | Default |
|---|---|---|
language |
String |
|
root |
String |
|
file |
String |
|
ops |
List<Map<String, Object>> |
|
server |
List<String> |
|
timeoutSeconds |
int |
Returns List<Map<String, Object>>
Raises SandboxException
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:109references()
Section titled “references()”def references(self, language: str, root: str, file: str, line: int, character: int, **options: Any) -> Any| Parameter | Type | Default |
|---|---|---|
language |
str |
|
root |
str |
|
file |
str |
|
line |
int |
|
character |
int |
|
options |
Any |
optional |
Returns Any
sdk/python/svm/lsp.py:131references(language: string, root: string, file: string, line: number, character: number, options?: { server?: string[]; timeout?: number })| Parameter | Type | Default |
|---|---|---|
language |
string |
|
root |
string |
|
file |
string |
|
line |
number |
|
character |
number |
|
options |
{ server?: string[]; timeout?: number } |
optional |
Returns Promise<unknown>
sdk/typescript/src/lsp.ts:138func (l *LanguageServers) References(ctx context.Context, language, root, file string, line, character int) (json.RawMessage, error)| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
language |
string |
|
root |
string |
|
file |
string |
|
line |
int |
|
character |
int |
Returns (json.RawMessage, error)
sdk/go/guest_lsp.go:248def references(language, root, file, line, character)| Parameter | Type | Default |
|---|---|---|
language |
||
root |
||
file |
||
line |
||
character |
sdk/ruby/lib/svm/language_servers.rb:88public Object references(String language, String root, String file, int line, int character)| Parameter | Type | Default |
|---|---|---|
language |
String |
|
root |
String |
|
file |
String |
|
line |
int |
|
character |
int |
Returns Object
sdk/java/src/main/java/dev/svm/sandbox/LanguageServers.java:139