# Lsp

## LspServer

### Constructors

#### Constructor

```ts
new LspServer(
   transport: HttpTransport,
   languageId: string,
   pathToProject: string): LspServer;
```

**Parameters**:

- `transport` _HttpTransport_
- `languageId` _string_
- `pathToProject` _string_

**Returns**:

- `LspServer`

### Methods

#### \[Symbol.asyncDispose\]()

```ts
[Symbol.asyncDispose](): Promise<void>;
```

**Returns**:

- `Promise<void>`

#### completions()

```ts
completions(
   uri: string,
   position: LspPosition,
   options: LspCompletionsOptions = {}): Promise<LspCompletionList>;
```

**Parameters**:

- `uri` _string_
- `position` _LspPosition_
- `options` _LspCompletionsOptions = \{\}_

**Returns**:

- `Promise<LspCompletionList>`

#### didClose()

```ts
didClose(uri: string): Promise<void>;
```

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<void>`

#### didOpen()

```ts
didOpen(uri: string): Promise<void>;
```

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<void>`

#### documentSymbols()

```ts
documentSymbols(uri: string): Promise<LspSymbol[]>;
```

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<LspSymbol[]>`

#### stop()

```ts
stop(): Promise<void>;
```

**Returns**:

- `Promise<void>`

#### workspaceSymbols()

```ts
workspaceSymbols(query: string): Promise<LspSymbol[]>;
```

**Parameters**:

- `query` _string_

**Returns**:

- `Promise<LspSymbol[]>`

***

## LspService

Sandbox LSP namespace.

Every call is scoped by `languageId` + `pathToProject`: the daemon keys one
language server per pair, starting it on demand and reusing it afterwards.
`start()` is therefore about controlling WHEN the server boots (and
surfacing `LSP_SERVER_UNAVAILABLE` when the image lacks it), not a
precondition the other calls can skip — they answer `LSP_NOT_STARTED`
rather than starting one implicitly.

### Constructors

#### Constructor

```ts
new LspService(transport: HttpTransport): LspService;
```

**Parameters**:

- `transport` _HttpTransport_

**Returns**:

- `LspService`

### Methods

#### start()

```ts
start(languageId: string, pathToProject: string): Promise<LspServer>;
```

Start the language server for a project.

**Parameters**:

- `languageId` _string_
- `pathToProject` _string_

**Returns**:

- `Promise<LspServer>`

***

## LspCompletionsOptions

**Properties**:

- `context?` _toolbox.CompletionRequest\['context'\]_

***

## LspCompletionItem

```ts
type LspCompletionItem = {
  [key: string]: unknown
} & Omit<toolbox.CompletionItem, 'documentation'> & {
  documentation?: unknown
}
```

One completion candidate. Shape follows the language server, so the
daemon passes items through with only `isIncomplete`/`items` normalized.

***

## LspCompletionList

```ts
type LspCompletionList = Omit<toolbox.CompletionList, 'items'> & { items: LspCompletionItem[] }
```

***

## LspLocation

```ts
type LspLocation = toolbox.SymbolLocation
```

***

## LspPosition

```ts
type LspPosition = toolbox.SymbolPosition
```

A zero-based LSP position.

***

## LspRange

```ts
type LspRange = toolbox.SymbolRange
```

***

## LspSymbol

```ts
type LspSymbol = toolbox.SymbolInfo
```

One symbol from `documentSymbols()` / `workspaceSymbols()`.