feat: LSP (Language Server Protocol) integration v3 — clean rebuild#3219
Open
TheArchitectit wants to merge 1 commit into
Open
feat: LSP (Language Server Protocol) integration v3 — clean rebuild#3219TheArchitectit wants to merge 1 commit into
TheArchitectit wants to merge 1 commit into
Conversation
Adds a complete LSP integration layer built cleanly on top of upstream/main,
without reverting any upstream commits.
Problem: The previous LSP client was a 747-line monolithic placeholder file
(lsp_client.rs) with no real language server communication. The dispatch
method returned placeholder JSON instead of interacting with actual LSP
servers. There was no way to discover, start, stop, or query language
servers, and no auto-enrichment of diagnostics in tool output.
Solution: Replace the placeholder with a fully functional, modular LSP
subsystem split across four crates under 500 lines each:
lsp_client/ (mod.rs, types.rs, dispatch.rs, tests.rs, tests_lifecycle.rs):
- LspRegistry with Arc<Mutex>-based thread-safe server tracking
- Lazy-start: servers auto-start on first dispatch() or file notification
- register_with_descriptor() for deferred process launch
- Full dispatch() routing for 12 LSP actions: diagnostics, hover,
definition, references, completion, symbols, format, code_action,
rename, signature_help, code_lens, workspace_symbols
- didOpen/didChange/didClose file notifications with diagnostic caching
- 58 unit tests covering registration, dispatch, lifecycle, edge cases
lsp_transport/ (mod.rs, tests.rs):
- JSON-RPC 2.0 transport over stdin/stdout with Content-Length framing
- TCP transport for GDScript/Godot LSP (port 6008) via socat/nc bridge
- Request/response multiplexing with server-initiated notification queuing
- Configurable request timeout (default 30s)
- NODE_NO_WARNINGS=1 for Node.js-based servers
- Graceful shutdown with kill fallback
lsp_process/ (mod.rs, parse.rs, tests.rs):
- Full LSP lifecycle: initialize -> initialized -> requests -> shutdown
- Comprehensive client capabilities declaration
- All LSP features: hover, goto_definition, references, completion,
document_symbols, formatting, didOpen/didChange/didClose,
code_action, rename, signature_help, code_lens, workspace_symbols
- Response parsing for all LSP result types (MarkupContent, MarkedString,
Location, DocumentSymbol, CompletionList, TextEdit, CodeAction,
WorkspaceEdit, Rename, SignatureHelp, CodeLens)
- Diagnostic draining from publishDiagnostics notifications
lsp_discovery.rs:
- Auto-discovery of 14 known LSP servers via PATH probing
- rustup proxy detection: falls back to 'rustup run stable rust-analyzer'
- Distro-aware install prompting (Debian, Fedora, Arch, openSUSE, Alpine,
Void, NixOS, macOS, pip, npm)
- GDScript/Godot TCP transport support
Existing file modifications (LSP-only additions):
- config.rs: LspServerConfig struct, lspAutoStart config field (default true),
lsp per-language config parsing, lsp()/lsp_auto_start() accessors
- lib.rs: pub mod lsp_discovery/lsp_process/lsp_transport declarations,
LspServerConfig/LspServerDescriptor exports
- commands/lib.rs: /lsp slash command (action, target args)
- tools/lib.rs: LSP diagnostic enrichment in read/write/edit file operations,
lsp_enrichment_for_path() and format_diagnostic_appendix() helpers,
expanded LSP tool definition with code_action, rename, signature_help,
code_lens, workspace_symbols actions
- main.rs: SlashCommand::Lsp match arms (resume_supported, unimplemented)
This is a clean rebuild from upstream/main. All 5 critical commits
(b64df99, 91a0681, c345ce6, 85e736c, 5b79413) are preserved.
The diff is LSP-only additions; no upstream code was reverted.
Related: PRs ultraworkers#2813, ultraworkers#3016, ultraworkers#3098, ultraworkers#3099 (all closed due to upstream reverts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
All previous LSP PRs (#2813, #3016, #3098, #3099) were closed by the repo owner because they reverted upstream commits. The existing
lsp_client.rswas a 747-line monolithic placeholder with no real language server communication -- thedispatch()method returned placeholder JSON instead of interacting with actual LSP servers.Solution
Clean rebuild of the entire LSP integration layer from
upstream/main, with zero upstream reverts. Replaced the placeholder with a fully functional, modular LSP subsystem split across four modules under 500 lines each.Changes
New files
rust/crates/runtime/src/lsp_client/(mod.rs, types.rs, dispatch.rs, tests.rs, tests_lifecycle.rs)LspRegistrywithArc<Mutex>-based thread-safe server trackingdispatch()or file notificationregister_with_descriptor()for deferred process launchdispatch()routing for 12 LSP actions: diagnostics, hover, definition, references, completion, symbols, format, code_action, rename, signature_help, code_lens, workspace_symbolsdidOpen/didChange/didClosefile notifications with diagnostic cachingrust/crates/runtime/src/lsp_transport/(mod.rs, tests.rs)NODE_NO_WARNINGS=1for Node.js-based serversrust/crates/runtime/src/lsp_process/(mod.rs, parse.rs, tests.rs)rust/crates/runtime/src/lsp_discovery.rsrustup run stable rust-analyzerModified files (LSP-only additions)
rust/crates/runtime/src/config.rs--LspServerConfigstruct,lspAutoStartconfig field (default true),lspper-language config parsing,lsp()/lsp_auto_start()accessorsrust/crates/runtime/src/lib.rs--pub mod lsp_discovery/lsp_process/lsp_transportdeclarations,LspServerConfig/LspServerDescriptorexportsrust/crates/commands/src/lib.rs--/lspslash command (action, target args)rust/crates/tools/src/lib.rs-- LSP diagnostic enrichment in read/write/edit file operations,lsp_enrichment_for_path()andformat_diagnostic_appendix()helpers, expanded LSP tool definition with code_action, rename, signature_help, code_lens, workspace_symbols actionsrust/crates/rusty-claude-cli/src/main.rs--SlashCommand::Lspmatch armsDiff verification
The 759 deletions are entirely from the old monolithic
lsp_client.rswhich was replaced by the properly modularizedlsp_client/directory. All modifications to existing files are LSP-only additions. No upstream code was reverted. All 5 critical commits (b64df99, 91a0681, c345ce6, 85e736c, 5b79413) are preserved.Testing
cargo check --workspace-- compiles cleanlycargo test -p runtime-- 610 tests pass (58 LSP-specific, including transport, process, discovery, client, and dispatch tests)cargo test -p api-- 11 tests passRelated PRs
Supersedes #2813, #3016, #3098, #3099 (all closed due to upstream reverts)