Files
bux-lang/vscode/README.md
T
dimgigov db7ba1dff2
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
feat: live LSP error underlines + improved VS Code extension
bux-lsp 0.17 publishes in-process diagnostics on open/change/save so
editors show red squiggles for lex/parse/type errors in the live buffer.
VS Code client discovers tools/bux-lsp, adds status bar/restart, richer
syntax/snippets, and docs (docs/LSP.md) for forum/editor setup.
2026-07-28 05:51:47 +03:00

90 lines
3.0 KiB
Markdown

# Bux Language Support for VS Code
Syntax highlighting, snippets, editor defaults, and **Language Server Protocol** integration for the [Bux](https://github.com/katehonz/bux) programming language.
## Features
| Area | What you get |
|------|----------------|
| **Syntax** | Keywords, types, `f"..."` interpolation, raw `` `...` `` strings, C-strings, macros (`macro!` / `name!()`), attributes (`@[Checked]`), numbers (hex/bin/oct + suffixes), lifetimes |
| **Snippets** | `main`, `func`, `struct`, `enum`, `match`, `interface`, `extend`, `macro`, `checked`, … |
| **LSP** | **Live error underlines** (red squiggles on edit), completion, hover, go-to-definition, references, rename, document/workspace symbols, call hierarchy, type hierarchy, go-to-implementation |
| **Editor** | Bracket colorization, smart indent / on-enter, fold regions (`// region`) |
| **Build** | `buxc` problem matcher for Tasks |
## Requirements
1. **VS Code** ≥ 1.85
2. **`bux-lsp`** binary (from this repo):
```bash
# from the Bux repository root
make lsp
# → tools/bux-lsp
```
The extension auto-discovers the server in this order:
1. Setting `bux.lsp.path` (absolute, relative, or command name)
2. `tools/bux-lsp` under any workspace folder (and parent folders for monorepos)
3. `bux-lsp` on your `PATH`
## Install (development)
```bash
cd vscode
npm install
npm run compile
# Launch Extension Development Host: F5 in VS Code,
# or install the folder as an extension:
code --install-extension .
# or package:
npx @vscode/vsce package
code --install-extension bux-lang-0.2.0.vsix
```
Symlink into your extensions dir (Linux):
```bash
ln -sfn "$(pwd)/vscode" ~/.vscode/extensions/bux-lang.bux-lang-0.2.0
```
## Commands
| Command | Description |
|---------|-------------|
| **Bux: Restart Language Server** | Stop and start `bux-lsp` |
| **Bux: Stop Language Server** | Disconnect the client |
| **Bux: Show Output Channel** | Open the Bux log |
Status bar item **Bux** (left): click to restart. Red = missing binary / start failure.
## Settings
| Setting | Default | Description |
|---------|---------|-------------|
| `bux.lsp.enabled` | `true` | Master switch for the language server |
| `bux.lsp.path` | `"bux-lsp"` | Path or command for the server binary |
| `bux-lsp.trace.server` | `off` | LSP wire trace (`off` / `messages` / `verbose`) |
## LSP capabilities (bux-lsp)
Provided by `tools/lsp_server.nim` (see `make lsp` / `make test-lsp`):
- `textDocument/completion`, `hover`, `definition`, `references`, `rename`
- `documentSymbol`, `workspace/symbol`
- Call hierarchy, type hierarchy, `implementation`
- Diagnostics on open/save (via analyzer / `buxc`)
## Troubleshooting
1. Status bar shows **error** → run `make lsp` and ensure `tools/bux-lsp` exists and is executable.
2. **Bux: Show Output Channel** for client logs.
3. Set `"bux-lsp.trace.server": "verbose"` for JSON-RPC traffic.
4. Confirm language mode is **Bux** for `.bux` files (status bar language indicator).
## License
MIT — same as the Bux project.