> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ubx lsp

> Start the ubx Language Server Protocol server for editor integration.

`ubx lsp` starts the Language Server Protocol (LSP) server on stdin/stdout. Editors that support LSP can connect to get inline diagnostics, hover documentation, code completion, and go-to-definition for `.xcl` files.

## Usage

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx lsp [flags]
```

## Flags

| Flag      | Description                                                |
| --------- | ---------------------------------------------------------- |
| `--stdio` | Use stdio (default; accepted for LSP client compatibility) |

## Features provided

* Inline diagnostics — typecheck errors appear as you type
* Hover documentation — resource type and property descriptions
* Code completion — block types, provider resources, input/locals references
* Go-to-definition — jump to resource, input, or output declarations
* Format on save — via LSP `textDocument/formatting`

## Important: Do not start from a terminal

The LSP uses JSON-RPC 2.0 over stdin/stdout. Starting it manually from a terminal corrupts the protocol stream. Always let your editor's LSP client manage the process.

## Editor setup

### VS Code

The ubx VS Code extension manages the LSP automatically. Install from the Marketplace.

### Neovim (nvim-lspconfig)

```lua theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
require('lspconfig').ubx.setup({
  cmd = { 'ubx', 'lsp' },
  filetypes = { 'xcl' },
  root_dir = require('lspconfig.util').root_pattern('workspace.xcl', '.git'),
})
```

### Helix

```toml theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
[language-server.ubx-lsp]
command = "ubx"
args = ["lsp"]
```

See [Editor setup](/v1/xcl/guides/editor-setup) for complete configuration.

## Logging

All LSP server output goes to stderr (never stdout — stdout is the protocol stream). Standard `log` output is redirected to stderr automatically.

## Exit behaviour

The server exits when the editor closes the connection. Error exit messages go to stderr; ubx does not print errors to stdout to avoid corrupting the JSON-RPC stream.
