35. Documentation
LSP Features
braid-lsp Overview
The braid-lsp server is written in Rust and implements the Language Server Protocol over stdio transport. It is defined in tools/bstudio/braid-lsp/ and uses the lsp-server crate for protocol handling.
Supported Features
| Feature | Capability | Status |
|---|---|---|
| Go-to-definition | textDocument/definition | Implemented (stub returns current line) |
| Hover type info | textDocument/hover | Planned |
| Autocomplete | textDocument/completion | Implemented (keywords: fn, let, import, struct, enum, match, if, else, while, return) |
| Diagnostics | textDocument/publishDiagnostics | Implemented (brace matching, syntax validation) |
| Text sync | textDocument/didOpen/didChange | Full sync mode (sync kind 1) |
Starting the LSP Server
Build and run braid-lsp from the source directory:
cd tools/bstudio cargo build --bin braid-lsp ./target/debug/braid-lsp
The server listens on stdio. It will output diagnostic messages to stderr and communicate JSON-RPC messages on stdout. To test manually:
echo '{'{'}
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {'{'}
"processId": null,
"capabilities": { '{'}{'}' }
{'}'}
{'}'}' | ./target/debug/braid-lspLSP Protocol Support
The server announces these capabilities during initialize:
{'{'}
"capabilities": {'{'}
"textDocumentSync": 1,
"completionProvider": {'{'}
"resolveProvider": false,
"triggerCharacters": ["."]
{'}'},
"definitionProvider": true
{'}'}
{'}'}- Text sync: Full document sync (value 1) — the server requests the entire document content on change
- Completion: Triggered on
.character; provides keyword completions with item kind classification - Definition: Go-to-definition support with URI and range response
- Diagnostics: Published automatically on document open and change, checking for unmatched braces