# Lsp (/docs/typescript-sdk/lsp)

## LspServer [#lspserver]

### Constructors [#constructors]

#### Constructor [#constructor]

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

**Parameters**:

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

**Returns**:

- `LspServer`

### Methods [#methods]

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

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

**Returns**:

- `Promise<void>`

#### closeDocument() [#closedocument]

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

Notify the server that the document at `uri` was closed.

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<void>`

#### completions() [#completions]

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

**Parameters**:

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

**Returns**:

- `Promise<LspCompletionList>`

#### documentSymbols() [#documentsymbols]

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

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<LspSymbol[]>`

#### openDocument() [#opendocument]

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

Notify the server that the document at `uri` was opened.

**Parameters**:

- `uri` _string_

**Returns**:

- `Promise<void>`

#### stop() [#stop]

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

**Returns**:

- `Promise<void>`

#### workspaceSymbols() [#workspacesymbols]

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

**Parameters**:

- `query` _string_

**Returns**:

- `Promise<LspSymbol[]>`

***

## LspService [#lspservice]

Sandbox LSP namespace.

Each language server is identified by `languageId` + `pathToProject`.
Call `start()` before other operations: an unavailable language server
raises `LSP_SERVER_UNAVAILABLE`, and operations on a server that has not
started raise `LSP_NOT_STARTED`.

### Constructors [#constructors-1]

#### Constructor [#constructor-1]

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

**Parameters**:

- `transport` _HttpTransport_

**Returns**:

- `LspService`

### Methods [#methods-1]

#### start() [#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 [#lspcompletionsoptions]

**Properties**:

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

***

## LspCompletionItem [#lspcompletionitem]

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

One completion candidate, with the shape supplied by the language server.

***

## LspCompletionList [#lspcompletionlist]

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

***

## LspLocation [#lsplocation]

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

***

## LspPosition [#lspposition]

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

A zero-based LSP position.

***

## LspRange [#lsprange]

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

***

## LspSymbol [#lspsymbol]

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

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