Skip to content

Dev/lsp#765

Open
cooffeeRequired wants to merge 2 commits into
crynta:mainfrom
cooffeeRequired:dev/lsp
Open

Dev/lsp#765
cooffeeRequired wants to merge 2 commits into
crynta:mainfrom
cooffeeRequired:dev/lsp

Conversation

@cooffeeRequired

Copy link
Copy Markdown

Summary

Adds optional Language Server Protocol (LSP) support to Terax’s built-in editor — without bundling language servers into the app binary.

This addresses #XXX (LSP support request). The design prioritizes a small Terax footprint: servers are resolved externally or installed on demand into app data, and the frontend LSP stack is lazy-loaded only when a supported file is opened.

Size impact

Area Impact
Terax app binary Language servers are not shipped inside Terax. The Rust side adds transport, process management, binary resolution, and an optional installer (~zip, tar, flate2, blocking reqwest). Measured release binary on Windows: ~7.7 MB (same order of magnitude as current Terax; exact delta vs main should be confirmed on CI/release builds).
Startup JS (eager bundle) No change — LSP is loaded via dynamic import() when a supported editor tab is opened. eager-budget tests pass; @codemirror is not in the eager graph.
Total client JS LSP code lives in a lazy chunk loaded on first use. Existing size budgets (540 KB startup / 1.5 MB total gzip) remain within limits when built from main-equivalent baseline.
Disk after “Install for Terax” Optional — servers + private Node/Go runtimes are stored under app data (…/lsp/), not in the Terax installer. Users who never enable LSP pay zero extra disk for servers.

Note to reviewers: Crynta’s concern about “Terax getting much bigger” applies mainly if we bundled servers. This PR deliberately avoids that — Terax stays a thin host; heaviness is opt-in and lives in app data or the user’s PATH.

What’s included

Editor (lazy-loaded LSP client)

  • Diagnostics, completions, hover, go-to-definition
  • Inactive-code highlighting (e.g. rust-analyzer #[cfg])
  • Inlay hints (e.g. deps-lsp version hints in manifests)
  • One shared server per (project root, server) with idle pooling
  • Multi-server documents (e.g. package.json → deps-lsp + JSON schema server)
  • Toggle: Settings → Languages → Enable language servers

Supported languages / servers

Group Server
Rust rust-analyzer
TypeScript / JavaScript typescript-language-server
Python pyright-langserver
Go gopls
C / C++ clangd
PHP intelephense
JSON & config vscode-json-language-server
Shell bash-language-server
Dependency manifests deps-lsp (package.json, Cargo.toml, go.mod, …)

Rust backend (src-tauri/src/modules/lsp/)

  • Transport: LSP Content-Length framing
  • Session: spawn/kill, stdin/stdout JSON-RPC, stderr channel
  • Resolve: whitelist + search order — linked path → Terax app data → system PATH → WSL link
  • Install: one-click “Install for Terax” (downloads into app data; includes private Node.js runtime where needed)
  • Links: manual path or WSL distro link when no local binary exists
  • Root detection: project root per file + server type

Settings UI

  • New Languages section: enable/disable LSP, probe status, install / link / unlink per server, WSL linking on Windows

Debug / DX

  • Status bar LSP button + command palette “LSP debug log”
  • Session states: idle | unsupported | spawning | ready | error | closed
  • Unit tests for protocol helpers, server mapping, diagnostics store, hover rendering

Architecture (high level)

@cooffeeRequired cooffeeRequired requested a review from crynta as a code owner June 8, 2026 20:48
@cooffeeRequired cooffeeRequired mentioned this pull request Jun 8, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants