Semantic Diff
#8425 Experimental ReScript Language Server in OCaml
141 commits
1659aee278c597fd00f46d1bde661d8bdfb841c7..pr-8425
update
add state
Extract server I/O into Server module and simplify handlers
- Move Io, Chan, and listen infrastructure to server.ml - Simplify on_request to take a packed request directly - Add basic hover response with markdown content - Rename public executable to rescript-language-server
Add parse_implementation_from_source and refactor LSP server
- Add parse_implementation_from_source to parsing/print engine types and all engine implementations, enabling parsing from a string source rather than a filename - Use parse_implementation_from_source in CompletionFrontEnd - Rename package from rescript-lsp to rescript-language-server - Refactor LSP server with typed state, document store, and diagnostics - Add hover support via completion backend integration
Split LSP into bin/src layout and add hover integration test
Move LSP modules under lsp/src/ with a thin lsp/bin/ entry point, add a configuration module, and introduce a tests/lsp_tests workspace exercising hover end-to-end.
Refactor analysis to decouple I/O from core logic
Splits Commands.ml into a pure layer that returns OCaml values (option, list, typed records like Protocol.hover, Protocol.signatureHelp, Protocol.completionItem) and a new analysis/src/Cli.ml that does the stringify-and-print step. analysis/bin/main.ml now dispatches to Cli.*, while the LSP server consumes Commands.* directly.
Makes the parsers accept source strings: res_driver gains parse_interface_from_source alongside the existing parse_implementation_from_source
Delegate hover logic to Analysis.Commands.hover
Rename tokenModifiersString to tokenModifiers with correct type
Update dune-project
Refactor LSP test infrastructure
- Rename Helper module to Client - Move expected output files into workspace directories - Improve request log format to show file path:line:col - Simplify hover.ml by removing intermediate result binding - Disable in-source compilation for basic-workspace
ci: add linux-headers
ci: add linux-headers-generic
ci: linux-libc-dev
ci: add build-essential
ci: add build-essential and linux-libc-dev
ci: update cache version to v5
ci: make Linux headers visible to musl-gcc
ci: support arm and disable test for build for ocaml 5.0
makefile: add test-lsp
Add LSP compiler diagnostics and file watching
Parse ReScript compiler logs into LSP diagnostics and keep diagnostic state in the language server so stale entries can be cleared when logs change. Read build roots from .sourcedirs.json to support monorepos and refresh diagnostics across all compiler logs instead of only the changed watch path.
Register dynamic workspace/didChangeWatchedFiles watchers after the client sends initialized, and add server-side request/response tracking so client responses to server requests no longer crash the input loop.
Tighten document store errors, thread the Eio environment through server state, update hover handling to use the current analysis API, and extend LSP tests to initialize the server before running workspace requests.
Comment to add more compiler log test
ci: add lsp test step
fix opam install ppx_expect
ppx_expect uses Jane Street-style opam versions like v0.17.2, not 0.17.2
ci: run test inside opam opam exec --
lsp: disable hover supports_markdown_links for now
Move Eio_main setup to LSP executable
Keep the language server library independent from Eio_main by exposing a listen function that accepts input, output, and filesystem handles. Store only the filesystem handle in LSP state and remove the unused environment from the server record.
ci: skip lsp tests on Windows
Expand LSP request handling and diagnostics
Advertise and implement the main language server capabilities using the existing analysis commands, including completion, signature help, definition, references, document symbols, code actions, code lenses, inlay hints, semantic tokens, rename, and formatting.
Rework diagnostics so compiler log diagnostics are treated as build snapshots, stale entries are cleared, and syntax diagnostics from the current in-memory document are appended on change. Also make document symbols source-based so the LSP can serve open documents without reading from disk.
Enforce LSP server lifecycle
Track initialize, running, and shutdown states in the LSP server loop. Reject requests before initialization with ServerNotInitialized, reject requests after shutdown with InvalidRequest, and allow exit notifications to terminate with the correct status code.
Also make unsupported requests and notifications explicit in the language server handlers.
analysis refactor: remove global state Shared_types.state
lsp: use analysis state
Revert "analysis refactor: remove global state Shared_types.state"
This reverts commit bbcb7b9388c5a577fa1fa71f5feabe881db1f978.
analysis: add state_to_yojson
lsp: refactor load_full
- Add package to server state - Add to_yojson in state
add minimal param to State.to_yojson
Makefile: skip test on Windows and update ci
refactor: add discover_subpackages_and_populate
fix type error from latest master merge
Improve LSP workspace initialization and package resolution
Resolve the workspace root from initialize params, initialize analysis state only after the server is initialized, and keep the active package in the initialized server state.
Populate analysis package caches for the workspace and dependencies. Resolve document requests against the package whose root best matches the document path, so nested package workspaces use the correct package metadata.
Implement code_actions.ml
lsp format: use rescript format command
Add code actions from compiler log
Add LSP configuration handling
Pull workspace configuration from the client and decode it into typed server settings for hover, code lens, inlay hints, and signature help behavior.
Route server-initiated request responses through an on_response handler so configuration updates do not block the LSP input loop
Circular dependency diagnostics: expand end character
Add LSP compiler config parsing
add code actions and custom requests
fix dune tests
code action: check for window/showDocuent support
Add LSP file navigation commands
Add code actions and execute commands for opening compiled output, creating interface files, switching between implementation/interface files, and dumping server state. Centralize filesystem access through option-based Eio helpers so LSP paths can be checked without raising.
chore: renames and minor fixes
add todo comments and minor fixes
add lsp.md
Update lsp.md
Omit empty document symbol children
DocumentSymbol.children is optional, so only set it when a symbol has nested entries. This avoids serializing leaf symbols with an empty children array.
Fix lsp document symbol
Update lsp.md
Add server notification rescript/compilationFinished
compiler_log: add warning number
add warning number in diagnostic message
Add more test to compiler log parser
Add cli
fix Neovim bug document symbol
minimal refactor on rescript_language_server.ml
support workspace/codeLens/refresh
Resolve runtime packages from workspace node_modules
Prefer package-manager installs under the active workspace when resolving dependencies, including Deno and pnpm node_modules layouts.
Keep Runtime_package.path as a compiler-development fallback so editor navigation does not jump from user projects into the server checkout.
build system: remove RESCRIPT_RUNTIME env var
Make Configuration unstrict
add more log message for invalid settings
dump server state: add configuration and order elements
Server request settings from item rescript.settings
move Exit to end
Support TextDocumentDiagnostic and improve TextDocumentDidOpen
Publish syntax error diagnostic on open document
Keep diagnostic sources separate
Track compiler diagnostics, compiler syntax diagnostics, and open-document syntax diagnostics independently so each source can be refreshed according to its own lifetime.
A syntax-only compiler log is an incomplete build snapshot, so keep existing type diagnostics until the next complete compiler snapshot or successful empty log. Open documents continue to use in-memory syntax diagnostics, while closed documents can fall back to compiler syntax diagnostics.
Use sourcedirs for initial compiler diagnostics
Read diagnostics from the compiler-log roots recorded in .sourcedirs.json so opening a document can publish the last known compiler diagnostics even when the compiler is not currently running.
Keep the root lib/bs/.compiler.log fallback only for older or partial builds without sourcedirs metadata, and document the diagnostic behavior and release notes.
remove double newline from message diagnostic
update analysis tests
refactor compiler log parser
cli, print to stderr
refactor compiler log to use option for range
Update compiler log tests snapshots
Update compiler_config.ml
Remove comment from code_actions.ml
Avoid duplicate syntax diagnostics on document changes
Do not push open-buffer syntax diagnostics through textDocument/publishDiagnostics on didChange. They are already available through textDocument/diagnostic.
Keep the changed URI force-published so any stale pushed syntax diagnostics are cleared when the filtered diagnostic set is empty.
minor fixes: add todo comment and fix typos in messages
workspace/configuration section must use rescript
Improve todo comments
Update lsp.md
Update lsp.md
Refactor cmt_viewer.dump for serve-side
Refactor execute commands. Move logic to module execute_commands.ml
Move format logic to module Formatter.ml
Refactor code, better error messages
Analysis cmt dump return a string instead a option
Update lsp.md
minor fixes
minor refactor
fix typo: Unknow -> Unknown
code actions: use %todo
Update lsp.md
Update lsp.md
lsp.md: fix typos
Add rescript_language_server.mli
update formatter and lsp.md
Resolve some TODOs
Restore get_runtime_dir in build_system.ml
Resolve todo resolve dep resolution using analysis
Remove signature help setting. Enable by default
Replace command rescript-vscode.go_to_location with native URls
file://name.res#LX,Y
Works in VSCode and Zed!!
Update lsp.md
Restore step ci Make Linux headers visible to musl-gcc
Update action.yml
Restore version in action.yml
Fix uring install on ci
Update lsp.md and add notes.md
Integrate lsp command into Rewatch
Make binary statically linked
Fix stale and flickering LSP diagnostics
Merge all diagnostic sources when serving requests and serializing state. Ignore partial compiler logs until #Done, then publish the completed snapshot and refresh pull diagnostics so clients clear resolved warnings without flickering.