Repository navigation
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
* 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. Signed-off-by: Pedro Castro <aspeddro@gmail.com> * add transform_opt for server-side use * analysis: add state_to_yojson * packages: add dependencies * Update CHANGELOG.md * Apply codex review suggestions * Refactor cmt_viewer.dump for serve-side * Analysis cmt dump return a string instead a option --------- Signed-off-by: Pedro Castro <aspeddro@gmail.com> Co-authored-by: Florian Hammerschmidt <florianh89@gmail.com>
Changelog🚀 New Feature
Semantic Diff168 commits · Full page Extract server I/O into Server module and simplify handlersd09d328 · aspeddro · May 12, 2026, 01:02 UTC - 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 server80e8218 · aspeddro · May 12, 2026, 18:49 UTC - Add Split LSP into bin/src layout and add hover integration testad0b764 · aspeddro · May 14, 2026, 08:11 UTC 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 logic5a36dd1 · aspeddro · May 16, 2026, 02:53 UTC Splits Makes the parsers accept source strings: Rename
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
* 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. Signed-off-by: Pedro Castro <aspeddro@gmail.com> * add transform_opt for server-side use * analysis: add state_to_yojson * packages: add dependencies * Update CHANGELOG.md * Apply codex review suggestions * Refactor cmt_viewer.dump for serve-side * Analysis cmt dump return a string instead a option --------- Signed-off-by: Pedro Castro <aspeddro@gmail.com> Co-authored-by: Florian Hammerschmidt <florianh89@gmail.com> Signed-off-by: Pedro Castro <aspeddro@gmail.com>
|
Codex review using GPT 6 Astra Ultra The new server has position-encoding and initialization compatibility bugs, incorrect package artifact resolution, and a formatter process leak. These affect ordinary editor workflows and require correction. Full review comments:
|
There was a problem hiding this comment.
This change makes analysis prefer the runtime installed in the project over the compiler-local runtime.
Previously, resolving @rescript/runtime bypassed the normal node_modules search and immediately returned Runtime_package.get_path (). During local LSP development, this could make “Go to definition” open runtime sources from the compiler checkout instead of the user’s project.
The resolver now searches the project and its ancestor directories first, including the .deno/node_modules and .pnpm/node_modules lookup locations. The compiler-local runtime remains a fallback for development environments where the project has no runtime installation.
This is not a complete Node/Deno/pnpm module resolver; it extends the existing package-directory lookup. The explicit RESCRIPT_RUNTIME override still takes precedence when selecting the analysis runtime.
Module resolution searches each directory and its ancestors for:
node_modules/<package>node_modules/.deno/node_modules/<package>node_modules/.pnpm/node_modules/<package>
| # first linux-x64 job runs them. | ||
| - os: ubuntu-24.04 | ||
| ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static | ||
| ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static |
There was a problem hiding this comment.
The CI compatibility job now uses OCaml 5.3 instead of 5.0 because the current test dependencies cannot be resolved on 5.0.
The compiler requires ppxlib >= 0.38.0. The language server’s ppx_expect dependency pulls in Jane Street PPXs whose versions compatible with that ppxlib require OCaml 5.3 or newer.
Changelog🚀 New Feature
Semantic Diff12 commits · Full page Add the OCaml ReScript language server28020ee · aspeddro · Nov 23, 2026, 13:16 UTC Ship the language server with the compiler so editor analysis uses the matching compiler metadata instead of a separately versioned executable. Consolidate the initial implementation, tests, documentation, and build integration while retaining the upstream master history. Command added (language-server entrypoint)
-rescript: build, watch, clean, format, compiler-args
+rescript: build, watch, clean, format, compiler-args, lsp --stdio
+The lsp subcommand runs the OCaml server over stdio using Eio.Connect LSP requests to the in-tree analysis library. Track editor syntax and compiler diagnostics separately, refresh analysis after builds, and provide configuration, navigation, interface creation, and debug commands. Add cross-platform stdio expect tests, editor setup documentation, CI integration, and third-party license notices for the linked dependencies. ✏️ Add --clientProcessId argument in lsp subcommand6c3b7b0 · aspeddro · Nov 17, 2026, 02:15 UTC · edited Accept the positive client PID that some editors append automatically so their standard launch command works. Keep --stdio mandatory and leave process monitoring outside this compatibility option. Command modified (LSP client compatibility)
-rescript lsp --stdio --clientProcessId 123: rejected
+rescript lsp --stdio --clientProcessId 123: accepted
+The PID must be a positive integer and is not monitored.Update CLI parsing tests and help snapshots for the optional argument. Keep the language server running after invalid input46e18ef · aspeddro · Nov 22, 2026, 22:02 UTC
Protocol modified (message error recovery)
-Malformed input: terminate the server.
-Request exception: terminate the server.
-Notification exception: terminate the server.
+Malformed input: skip it and continue reading.
+Request exception: return a JSON-RPC error and retain session state.
+Notification exception: log to stderr and continue reading.Diagnostic modified (document store)
-InvalidRequest: Document store not found <uri> to get
+RequestFailed: Cannot get document <uri>: it is not open.Add end-to-end snapshots for error recovery, state preservation, and clean shutdown. Capture subprocess stderr and preserve actual exit codes. Verified with dune runtest and make dead-code. ✏️ Back to
|
|
Thanks for this, @aspeddro! Running the analysis code in-process behind The bug list comes from a review by Claude (at 00aaba1). Claude read the code, built the PR on linux-arm64 (OCaml 5.5.2), and checked each finding with a small LSP client against Design1. DependenciesThe PR adds a lot of new dependencies (about 30 new license entries). I don't think all of them are needed:
Without these, the new runtime dependencies would be just 2. Where the data comes fromRight now everything is read from disk after the build wrote it:
Keeping the build and the LSP separate, as the PR does, is probably the safer choice, since we had bad experiences with editor integrations that run the watcher. But reading text logs back is fragile, and a later phase could do better while the build stays a separate process:
It would help if the design left room for this now. For example, the diagnostics source and the BugsHigh1. One bad message ends the server. Reproduced. In
Could you wrap each handler and turn exceptions into an error response? For notifications, log the error and keep the old state. This also covers exceptions from 2. A request with invalid params resets the state ( 3. Messages larger than 1 MB end the server ( Medium
Low
Checked and fine: incremental edits with UTF-16 positions, TestsThe end-to-end snapshots through the real CLI are a good base. Missing are:
CommitsThe PR is hard to review in one piece, and its 201 commits need cleaning up anyway (the Semantic Diff check fails because most of them have only a subject line). Could you squash it into a few clean commits, so we can review it step by step? For example:
My priorities: the three high bugs, then the dependency question, then the commit cleanup. Structured data from the watcher and type checking of unsaved buffers can come later. |
|
One thing that affects clients that run more than one instance of the server: in VS Code, each ReScript project in a window gets its own The vscode-languageclient maintainer considers this intended and recommends making the command IDs unique per server instance (microsoft/vscode-languageserver-node#333, #607):
Proposal:
On the VS Code side this lets us drop a workaround that patches vscode-languageclient's internals, and calls go automatically to the server that produced the code action. Neovim and Zed should be unaffected, since they execute whatever ID the code action carries. |
|
Tested the pkg.pr.new build at 00aaba1 from VS Code: |
@fhammerschmidt Yes, I added in cd7dbf8 (Just wait for the CI) |
|
On Windows, open files lose their compiler errors. We hit this in the end-to-end tests of the new VS Code extension, running against this PR's build (cd7dbf8). Cause: the drive letter's case. What the client sees after opening The error ends up neither pushed nor pulled. Windows terminals almost always use an uppercase drive ( A smaller related point: open documents are left to pull diagnostics, but vscode-languageclient only pulls for documents visible in an editor. A document that is open without an editor (for example opened by another extension) therefore gets no diagnostics at all. That may well be acceptable, but it's how our tests first lost diagnostics. |
Ship the language server with the compiler so editor analysis uses the
matching compiler metadata instead of a separately versioned executable.
Consolidate the initial implementation, tests, documentation, and build
integration while retaining the upstream master history.
Command added (language-server entrypoint):
Before (text):
rescript: build, watch, clean, format, compiler-args
After (text):
rescript: build, watch, clean, format, compiler-args, lsp --stdio
The lsp subcommand runs the OCaml server over stdio using Eio.
Connect LSP requests to the in-tree analysis library. Track editor syntax
and compiler diagnostics separately, refresh analysis after builds, and
provide configuration, navigation, interface creation, and debug commands.
Add cross-platform stdio expect tests, editor setup documentation, CI
integration, and third-party license notices for the linked dependencies.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
…cript - Projects can initialize in the same VS Code window. Plain command names remain supported for direct client calls. Fix bug reported in rescript-lang#8425 (comment) Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Accept the positive client PID that some editors append automatically so
their standard launch command works. Keep --stdio mandatory and leave
process monitoring outside this compatibility option.
Command modified (LSP client compatibility):
Before (text):
rescript lsp --stdio --clientProcessId 123: rejected
After (text):
rescript lsp --stdio --clientProcessId 123: accepted
The PID must be a positive integer and is not monitored.
Update CLI parsing tests and help snapshots for the optional argument.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Why:
A malformed message or handler exception could terminate the server,
interrupting unrelated editor requests.
Protocol modified (message error recovery):
Before (text):
Malformed input: terminate the server.
Request exception: terminate the server.
Notification exception: terminate the server.
After (text):
Malformed input: skip it and continue reading.
Request exception: return a JSON-RPC error and retain session state.
Notification exception: log to stderr and continue reading.
Diagnostic modified (document store):
Before (diagnostic):
InvalidRequest: Document store not found <uri> to get
After (diagnostic):
RequestFailed: Cannot get document <uri>: it is not open.
Add end-to-end snapshots for error recovery, state preservation, and
clean shutdown. Capture subprocess stderr and preserve actual exit codes.
Verified with dune runtest and make dead-code.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Request parameter decoding failures describe invalid client input, not
internal server failures. Return the appropriate JSON-RPC error code and
update the protocol regression snapshot, retaining the initialized state.
Protocol modified (invalid request parameters):
Before (text):
Invalid hover parameters -> InternalError (-32603)
After (text):
Invalid hover parameters -> InvalidParams (-32602)
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Why:
Reading an entire body through the 1 MiB input buffer rejected
large documents and left the server unable to process later messages.
Protocol modified (message body reads):
Before (text):
Read the entire Content-Length body in one buffered operation.
Bodies larger than 1 MiB exceed the reader limit.
After (text):
Keep direct reads for bodies up to 1 MiB.
Assemble larger bodies from chunks no larger than 1 MiB.
Consume exactly Content-Length bytes, preserving the next header.
Add regression tests for opening and editing documents over 2 MiB,
including subsequent requests to verify message framing remains intact.
Verified with dune runtest, make dead-code, and changelog validation.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
… interface Advertise its command, and refuse to overwrite existing interface files Signed-off-by: Pedro Castro <aspeddro@gmail.com>
…executable - Leave documents with syntax errors unchanged without error popups. Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Normalize the language-server library's dependency list to Dune's compact formatting. This changes no dependencies or build behavior. Signed-off-by: Pedro Castro <aspeddro@gmail.com>
…cript - Projects can initialize in the same VS Code window. Plain command names remain supported for direct client calls. Fix bug reported in rescript-lang#8425 (comment) Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Why:
Compiler logs and editors can use different drive-letter casing.
Structural URI comparison treats these as separate documents,
causing compiler errors to disappear when a file opens.
Representation modified (document and diagnostic keys):
Before (text):
D:/project/Broken.res and d:/project/Broken.res use separate keys.
Pull diagnostics for the open document return an empty list.
After (text):
Serialized URI keys identify both paths as the same document.
Pull diagnostics retain compiler errors.
Filename case remains distinct.
Add unit and end-to-end regressions for URI lookup, diagnostic merging,
open/close ownership, and clearing errors after a clean build.
Document the unchanged pull behavior for documents without an editor.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Why:
The LSP maintained a separate rescript.json decoder whose defaults
and namespace rules could diverge from the build system.
Representation modified (project configuration):
Before (text):
The LSP decodes its own partial schema and computes artifact paths.
Missing package-specs defaults to CommonJS out-of-source output.
After (text):
Config.of_string decodes Eio-loaded contents using the build schema.
Rewatch helpers resolve namespaces and generated artifact paths.
Missing package-specs uses the build's ES module in-source default.
Keep ppx_deriving_yojson for editor settings and decode source-directory
metadata with Yojson directly. Update documentation and license scopes.
Add tests for decoder parity, output defaults, multiple outputs,
namespaces, settings validation, and malformed source-directory metadata.
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Keep ppx_expect and its transitive runtimes out of the shipped rescript binary by moving all 13 inline tests to tests/lsp_unit_tests. Extract rescript_language_server_core so tests exercise the production implementation while preserving the existing listen interface. Run both LSP suites through make test-lsp and update the documentation. Remove the unlinked test dependencies from the license inventory and regenerate the third-party notices Signed-off-by: Pedro Castro <aspeddro@gmail.com>
This branch introduces a ReScript LSP server built on top of the existing
analysislibrary. It runs in-process throughrescript lsp --stdio, using thenew
rescriptCLI written in OCaml (rewatch-ocaml). There is no separaterescript-language-serverexecutable. It's a separate, OCaml-side explorationalongside the Rust/rewatch-based experiment in #8243, the two share the same
goal (a LSP server for ReScript) but approach it from different ends of the
toolchain.
Why rewriting the server in OCaml is a good fit
The editor features are already implemented in the OCaml analysis library.
Hover, completion, references, rename, document symbols, code actions, and
diagnostics all depend on compiler data structures such as
.cmt/.cmti,typed trees, locations, package metadata, and compiler diagnostics. Running the
LSP server in OCaml lets the server call those APIs directly instead of shelling
out to
rescript-editor-analysis.exeor passing JSON through stdin. Thatremoves a large amount of process orchestration and serialization glue, and
keeps the LSP closer to the compiler types it needs to understand. This also
makes the server easier to evolve with the compiler. When typedtree, diagnostic
formats, package discovery, or
.cmthandling changes, the LSP can be updatedin the same language and build system as the analysis code. That reduces version
skew and makes bugs easier to reproduce with Dune/expect tests.
Why ship the language server with the compiler
The language server is tightly coupled to the compiler version used by a
project. It reads
.cmtand.cmtifiles containing marshalled compilerinternals such as
Typedtree,Types, andEnv. These files are not a stable,schema-aware protocol: changing one of those OCaml types can make an analysis
binary incompatible with artifacts produced by another compiler revision.
This is not only a theoretical compatibility concern. In
#8475, adding typedtree
constructors for
for...ofwithout changing the CMT magic number allowed anewer analysis binary to read incompatible ReScript 12 artifacts and
segmentation fault. The same class of failure appeared after record-rest changes
altered compiler data stored in CMT files. Bumping the CMT magic number makes
these mismatches rejectable, but the project must still be rebuilt with the
matching compiler.
Shipping the server in the same platform package as the compiler, and exposing
it through
rescript lsp --stdio, gives clients one project-local entrypoint.The selected ReScript dependency then supplies
bsc, the analysis code, and thelanguage server from the same release. This has several practical benefits:
rescriptexecutable links the server library directly, so noseparate language-server executable needs to be located or launched.
Bundling does not make stale artifacts safe. Compiler changes that alter
marshalled CMT data must still bump the magic number, and the server should turn
version mismatches into an actionable request to rebuild. A separately versioned
server becomes practical only if analysis moves to a stable, explicitly
versioned artifact format or maintains decoders for multiple compiler-internal
formats. Until then, promising one server binary that supports multiple compiler
versions would hide a compatibility boundary that already exists.
What's here
lsp/src, with its own opam package(
rescript-language-server.opam). It useslsp(>= 1.22.0),eio,ppx_deriving_yojson,ppx_expectand the in-treeanalysislibrary.rewatch-ocaml/rescript_ocaml.ml. The OCamlrescriptexecutable links the server library and uses
Eio_main.runto supply itsfilesystem, stdin and stdout.
rescript lsp --stdio. The--stdioflag is required:rescript lspwithout it fails and displays usage help. The LSP subcommanddoes not accept
--quietor--verbose.tests/lsp_testsexercise the server through thesame OCaml CLI entrypoint.
Status / what's not here yet
The main objective is to first maintain feature parity with the current server
(server.ts) as much as possible. Below is a list of some requests and
notifications. Some are out of scope because they don't make sense.
initialize- client requestinitialized- client notificationshutdown- client requestexit- client notificationtextDocument/didOpen- client notificationtextDocument/didChange- client notificationtextDocument/didClose- client notificationtextDocument/didSave- client notification - It will not beimplemented for now.
textDocument/hover- client requesttextDocument/publishDiagnostics- server notificationdependency errors be published?
does not point at a precise source range. When the document is open, we
expand the diagnostic range to cover the whole document so the editor can
display a file-level diagnostic. If the document is not open, we keep the
range parsed from the compiler log, i.e.,
{start: {line: 0, character: 0}, end: {line: 0, character: 6}}let a=1.Protocol positions are zero-based, so the position is
length - 1.Analysisfor syntax errors and ignore them in the compiler logparser.
TextDocumentDidChangeandprovide instant feedback.
.compiler.log- server featurecompiler_log.ml. Seetests/build_testsfor more examples.
.sourcedirs.json- server feature.sourcedirs.jsonis alwaysgenerated with
build_rootfield for each subpackage.workspace/didChangeWatchedFiles- client notification.compiler.logfiles, which usually means a ReScript build has finished.When a watched log changes, the server re-reads every known compiler log and
republishes diagnostics so stale errors are cleared and monorepo diagnostics
stay in sync.
GlobPatternwithbaseUri(workspace root)?rescript.jsonfiles in the workspace root?rescript.json. For example,suffixandpackage-specsare needed to create the code actionOpen compiled JS file. Changes independenciesimpact variousfunctionalities because they modify the state in
Analysis.Shared_types.state.client/registerCapability- server requestworkspace/didChangeWatchedFilesis commonly registereddynamically. The server does not know all file-watch patterns during the
static
initializeresponse. In this LSP, the watcher list depends onproject state, especially
.sourcedirs.json, which tells us where eachReScript build root lives. In monorepos, that means the server needs to
register watchers for compiler logs after initialization, once it has
workspace context. That means watching generated
.compiler.logfiles. Whenthe client sees one change, it sends
workspace/didChangeWatchedFiles, andthe server refreshes diagnostics.
textDocument/diagnostic- client requesttextDocument/completion- client requestcompletionItem/resolve- client requesttextDocument/signatureHelp- client requesttextDocument/definition- client requesttextDocument/declaration- client request - It will not be implementedfor now.
textDocument/typeDefinition- client requesttextDocument/implementation- client request - It will not beimplemented for now.
textDocument/references- client requestSupport v12 CMT files in analysis #8477
textDocument/documentHighlight- client request - It will not beimplemented for now.
textDocument/documentSymbol- client request"document_symbols": "on"configuration. When enabled,tree-sitter is not used for document symbols.
workspace/symbol- client request - It will not be implemented fornow.
textDocument/codeAction- client requestrescript/openCompiled)window/showDocument.rescript/createInterface)rescript/switchImplementationInterface)window/showDocumentrequest.codeAction/resolve- client request - It will not be implemented fornow.
textDocument/codeLens- client requestworkspace/codeLens/refresh- server requestcodeLens/resolve- client request - It will not be implemented fornow.
textDocument/inlayHint- client requestinlayHint/resolve- client request - It will not be implemented fornow.
textDocument/semanticTokens/full- client requesttextDocument/semanticTokens/full/delta- client request - It will notbe implemented for now.
textDocument/semanticTokens/range- client request - It will not beimplemented for now.
textDocument/rename- client requesttextDocument/prepareRename- client requesttextDocument/formatting- client requesttextDocument/rangeFormatting- client request - It will not beimplemented for now.
textDocument/onTypeFormatting- client request - It will not beimplemented for now.
textDocument/foldingRange- client request - It will not beimplemented for now.
textDocument/selectionRange- client request - It will not beimplemented for now.
textDocument/documentLink- client request - It will not beimplemented for now.
documentLink/resolve- client request - It will not be implemented fornow.
textDocument/documentColor- client request - It will not beimplemented for now.
textDocument/linkedEditingRange- client request - It will not beimplemented for now.
workspace/didChangeConfiguration- client notificationworkspace/configuration- server requestworkspace/executeCommand- client requestrescript/dumpServerStateState.t(diagnostics, document store, status, configuration,analysis state (
Analysis.Shared_types.state) and compiler config)..jsonfile and open it usingwindow/showDocument.Requires client support for that request; the command returns no content.
rescript/openCompiled: Triggered by a code actionwindow/showDocument.rescript/createInterface: Triggered by a code actioninterface file if the client supports the
window/showDocumentrequest.rescript/switchImplementationInterface: Triggered by a code actionwindow/showDocumentrequest.rescript/dumpCmt: Dump cmt file content.txtfile and open it usingwindow/showDocument.Requires client support for that request; the command returns no content.
rescript/dumpParseTreeIt will not be implemented for now.rescript/dumpTypedTreeIt will not be implemented for now.window/showDocumentrequest.LSP: support windows/showDocument zed-industries/zed#58099.
textDocument/openCompiled- client requesttextDocument/createInterface- client requesttextDocument/switchImplementationInterface: Currently it's done on theclient side, but it could be a command triggered by a code action.
rescript/startBuild- client request - How the build integrationwill be done. See last point. It will not be implemented for now
initialization and drop this custom request?
rescript/stopBuild?rescript/compilationFinished- server notification - Sent from theserver to the client when compilation is finished
server.ts) sends this notification, and the VSCode clientuses it to run Code Analysis. The server sends it when
.compiler.logchanges. Only VSCode uses this notification.
reanalyze may be integrated into the server instead of running on the
client side.
$/progressserver notification?rescript/compilationStatus- server notification - Sends thecompilation status from the server to the client.
bar. Only VSCode uses this notification.
$/progressserver notification?server.ts) supports stdio and node-ipc. The VSCodeclient uses node-ipc. This implementation supports only stdio.
not be implemented for now.
not be implemented for now.
produced by an existing
rescript build, rather than the LSP starting ormanaging builds itself.
for now. Idea to explore.
Tests
tests/lsp_tests/contains OCamlppx_expectend-to-end tests, with a namedlet%expect_testfor each scenario and separate modules for each feature.Representative cases are adapted from
tests/analysis_tests; the originalanalysis suite remains in place. Source snippets no longer contain cursor
markers: requests use explicit, zero-based LSP positions.
The shared client in
test.mlstartsrewatch-ocaml/rescript_ocaml.exe lsp --stdiothroughUnix.open_process_args,avoiding
Eio.Stdenv.process_mgrin the test harness so it can run on Windows,Linux and macOS. Dune declares the CLI executable as a test dependency. The
harness supplies
RESCRIPT_RUNTIMEbecause it bypasses the npm launcher.Tests create their source files and
rescript.jsonfrom OCaml.Test.setup_projectwrites the project and optionally builds it;Test.with_projectmanages a temporary workspace and cleanup. Tests can addmultiple documents, edit unsaved buffers, rebuild, change settings and vary
client capabilities. Snapshots normalize temporary workspace paths while
preserving ranges and response ordering.
Coverage includes hover and JSX hover, completion and JSX completion, completion
resolution, definitions, type definitions, references, prepare rename, rename,
document symbols, semantic tokens, signature help, interface creation, code
actions, inlay hints, syntax diagnostics and code lenses. Diagnostic regression
tests cover build-log updates, stale warnings, duplicate publications, flicker
and document closure. Execute-command tests check the temporary state/CMT dump
files and
window/showDocumentcapability handling. These tests do not implycomplete coverage or feature parity with the existing server.
Build the toolchain and runtime and run the LSP suite with:
opam exec -- make test-lspAfter the toolchain and runtime are built, run just the integration suite with
opam exec -- dune runtest tests/lsp_tests. Runopam exec -- dune runtesttoalso cover inline tests in the server library, including
.sourcedirs.jsonbuild-root extraction and
.compiler.logparsing. Seethe snapshot test guide for helpers and commands
to review and promote snapshots.
Breaking Changes
initializationOptions. This server ignoressettings coming from
initializationOptions. SeeSpec should discourage abuse of initializationOptions and didChangeConfiguration microsoft/language-server-protocol#567 (comment).
We use
workspace/configuration.rescript/dumpServerStateandrescript/dumpCmtopen temporary files throughwindow/showDocumentinstead of returning a JSON object with acontentfield. Clients need to support that request and no longer need to create their
own buffers from the command result.
Server settings
Proposed interface.
supportMarkdownLinksis not a setting. It's a greatfeature, but some clients don't have good support; Neovim are a example.
Therefore, I'm promoting it to a setting so users can enable or disable it.
Release and transition plan
the configuration example.
Other related topics
Refactor analysis for use on the server side
#8426
#8466
#8478
yojsonandlsplibraries in the analysis library##8436
Shared_types.state#8465