Semantic Diff

#8425 Experimental ReScript Language Server in OCaml

141 commits

1659aee278c597fd00f46d1bde661d8bdfb841c7..pr-8425

693422ce4 · aspeddro · Dec 01, 2024, 15:31 UTC

initial lsp

129af21f0 · aspeddro · Apr 29, 2026, 03:06 UTC

update

6b65a255c · aspeddro · Apr 30, 2026, 12:13 UTC

add state

e2989d039 · aspeddro · May 12, 2026, 01:02 UTC

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

a99abc674 · aspeddro · May 12, 2026, 18:49 UTC

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

365836c99 · aspeddro · May 14, 2026, 08:11 UTC

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.

169262900 · aspeddro · May 16, 2026, 02:53 UTC

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

743126f8c · aspeddro · May 16, 2026, 02:54 UTC

Delegate hover logic to Analysis.Commands.hover

0e522be0a · aspeddro · May 16, 2026, 03:53 UTC

Rename tokenModifiersString to tokenModifiers with correct type

9df90792f · aspeddro · May 22, 2026, 13:17 UTC

Update dune-project

29cd3d794 · aspeddro · May 31, 2026, 20:39 UTC

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

a20da0da8 · aspeddro · May 31, 2026, 21:06 UTC

ci: add linux-headers

5a57bbc5e · aspeddro · May 31, 2026, 21:19 UTC

ci: add linux-headers-generic

9442c4b26 · aspeddro · May 31, 2026, 21:57 UTC

ci: linux-libc-dev

64dffd856 · aspeddro · May 31, 2026, 22:11 UTC

ci: add build-essential

e0f6296df · aspeddro · May 31, 2026, 23:16 UTC

ci: add build-essential and linux-libc-dev

8cebaf2c6 · aspeddro · May 31, 2026, 23:30 UTC

ci: update cache version to v5

85138b109 · aspeddro · Jun 01, 2026, 23:26 UTC

ci: make Linux headers visible to musl-gcc

66b69febf · aspeddro · Jun 01, 2026, 23:56 UTC

ci: support arm and disable test for build for ocaml 5.0

c50f61325 · aspeddro · Jun 02, 2026, 01:13 UTC

makefile: add test-lsp

890fd1695 · aspeddro · Jun 05, 2026, 20:35 UTC

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.

39639c686 · aspeddro · Jun 06, 2026, 16:37 UTC

Comment to add more compiler log test

5e002cb88 · aspeddro · Jun 06, 2026, 16:41 UTC

ci: add lsp test step

5781622f5 · aspeddro · Jun 06, 2026, 16:51 UTC

fix opam install ppx_expect

ppx_expect uses Jane Street-style opam versions like v0.17.2, not 0.17.2

728c4bff6 · aspeddro · Jun 06, 2026, 17:12 UTC

ci: run test inside opam opam exec --

33edc8539 · aspeddro · Jun 06, 2026, 17:27 UTC

lsp: disable hover supports_markdown_links for now

75a61238a · aspeddro · Jun 06, 2026, 18:05 UTC

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.

126f67ad5 · aspeddro · Jun 06, 2026, 18:21 UTC

ci: skip lsp tests on Windows

5d14a575f · aspeddro · Jun 07, 2026, 03:50 UTC

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.

015a2d2d0 · aspeddro · Jun 07, 2026, 18:51 UTC

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.

bbcb7b938 · aspeddro · Jun 07, 2026, 20:10 UTC

analysis refactor: remove global state Shared_types.state

b63a60f31 · aspeddro · Jun 07, 2026, 20:12 UTC

lsp: use analysis state

88190b961 · aspeddro · Jun 08, 2026, 15:19 UTC

Revert "analysis refactor: remove global state Shared_types.state"

This reverts commit bbcb7b9388c5a577fa1fa71f5feabe881db1f978.

3be179c26 · aspeddro · Jun 08, 2026, 23:26 UTC

analysis: add state_to_yojson

9bc661c3b · aspeddro · Jun 08, 2026, 23:28 UTC

lsp: refactor load_full

- Add package to server state - Add to_yojson in state

8ec52ae16 · aspeddro · Jun 09, 2026, 02:11 UTC

add minimal param to State.to_yojson

22a5eebe1 · aspeddro · Jun 09, 2026, 02:31 UTC

Makefile: skip test on Windows and update ci

16e4fb263 · aspeddro · Jun 10, 2026, 16:11 UTC

refactor: add discover_subpackages_and_populate

67a741f25 · aspeddro · Jun 10, 2026, 16:15 UTC

fix type error from latest master merge

d9ca15629 · aspeddro · Jun 10, 2026, 18:41 UTC

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.

ac07b29d5 · aspeddro · Jun 13, 2026, 12:27 UTC

Implement code_actions.ml

ba293abff · aspeddro · Jun 13, 2026, 20:04 UTC

lsp format: use rescript format command

87e280dc3 · aspeddro · Jun 13, 2026, 22:51 UTC

Add code actions from compiler log

9f6c8051f · aspeddro · Jun 14, 2026, 01:31 UTC

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

b4e797cd0 · aspeddro · Jun 14, 2026, 01:54 UTC

Circular dependency diagnostics: expand end character

1566ae2a6 · aspeddro · Jun 14, 2026, 23:46 UTC

Add LSP compiler config parsing

fc76cba9e · aspeddro · Jun 14, 2026, 23:46 UTC

add code actions and custom requests

2fae316f0 · aspeddro · Jun 14, 2026, 23:48 UTC

fix dune tests

0107015ec · aspeddro · Jun 15, 2026, 03:13 UTC

code action: check for window/showDocuent support

85942cd2f · aspeddro · Jun 16, 2026, 00:37 UTC

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.

2bcd31266 · aspeddro · Jun 16, 2026, 01:11 UTC

chore: renames and minor fixes

879995de8 · aspeddro · Jun 16, 2026, 01:24 UTC

add todo comments and minor fixes

e246eef7f · aspeddro · Jun 16, 2026, 01:29 UTC

add lsp.md

b9d2730ec · aspeddro · Jun 16, 2026, 02:56 UTC

Update lsp.md

55d043192 · aspeddro · Jun 17, 2026, 15:40 UTC

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.

4194057a8 · aspeddro · Jun 17, 2026, 15:41 UTC

Fix lsp document symbol

cc7ed4fa3 · aspeddro · Jun 17, 2026, 15:41 UTC

Update lsp.md

de0823236 · aspeddro · Jun 17, 2026, 23:45 UTC

Add server notification rescript/compilationFinished

1152368d6 · aspeddro · Jun 17, 2026, 23:59 UTC

compiler_log: add warning number

d2afdeda5 · aspeddro · Jun 18, 2026, 00:07 UTC

add warning number in diagnostic message

d3cfd95ab · aspeddro · Jun 18, 2026, 01:42 UTC

Add more test to compiler log parser

11ac54179 · aspeddro · Jun 18, 2026, 02:18 UTC

Add cli

1ccc66ee8 · aspeddro · Jun 19, 2026, 01:35 UTC

fix Neovim bug document symbol

94d0d878f · aspeddro · Jun 19, 2026, 01:36 UTC

minimal refactor on rescript_language_server.ml

2943e98eb · aspeddro · Jun 19, 2026, 03:24 UTC

support workspace/codeLens/refresh

0c4e43a56 · aspeddro · Jun 19, 2026, 14:28 UTC

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.

47bae3b87 · aspeddro · Jun 19, 2026, 14:29 UTC

build system: remove RESCRIPT_RUNTIME env var

5133b39a6 · aspeddro · Jun 19, 2026, 20:26 UTC

Make Configuration unstrict

a41e58083 · aspeddro · Jun 19, 2026, 20:28 UTC

add more log message for invalid settings

9a1bbb8e5 · aspeddro · Jun 19, 2026, 20:29 UTC

dump server state: add configuration and order elements

08d0f4848 · aspeddro · Jun 19, 2026, 20:30 UTC

Server request settings from item rescript.settings

e0dcc887e · aspeddro · Jun 19, 2026, 20:30 UTC

move Exit to end

d8e0e6758 · aspeddro · Jun 19, 2026, 21:20 UTC

Support TextDocumentDiagnostic and improve TextDocumentDidOpen

Publish syntax error diagnostic on open document

7c7c209df · aspeddro · Jun 19, 2026, 22:02 UTC

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.

58131570d · aspeddro · Jun 19, 2026, 22:17 UTC

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.

393a6c3c3 · aspeddro · Jun 19, 2026, 22:33 UTC

remove double newline from message diagnostic

dd758b8b4 · aspeddro · Jun 19, 2026, 22:34 UTC

update analysis tests

81b6f1d56 · aspeddro · Jun 20, 2026, 00:16 UTC

refactor compiler log parser

d18955c8e · aspeddro · Jun 20, 2026, 01:29 UTC

cli, print to stderr

abf974303 · aspeddro · Jun 20, 2026, 01:41 UTC

refactor compiler log to use option for range

e3eab6eac · aspeddro · Jun 20, 2026, 12:13 UTC

Update compiler log tests snapshots

0eef9a4d0 · aspeddro · Jun 20, 2026, 12:14 UTC

Update compiler_config.ml

07cfb9709 · aspeddro · Jun 20, 2026, 12:14 UTC

Remove comment from code_actions.ml

3737687ad · aspeddro · Jun 20, 2026, 14:13 UTC

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.

1fd941430 · aspeddro · Jun 20, 2026, 14:14 UTC

minor fixes: add todo comment and fix typos in messages

acb52a5a5 · aspeddro · Jun 20, 2026, 15:47 UTC

workspace/configuration section must use rescript

2f10c7f2a · aspeddro · Jun 20, 2026, 17:04 UTC

Improve todo comments

f8c0d4a79 · aspeddro · Jun 20, 2026, 17:21 UTC

Update lsp.md

42fe2ae59 · aspeddro · Jun 20, 2026, 17:27 UTC

Update lsp.md

be8143425 · aspeddro · Jun 20, 2026, 22:04 UTC

Refactor cmt_viewer.dump for serve-side

c80ae00a9 · aspeddro · Jun 21, 2026, 00:12 UTC

Refactor execute commands. Move logic to module execute_commands.ml

6ddcce597 · aspeddro · Jun 21, 2026, 00:23 UTC

Move format logic to module Formatter.ml

2d411c96d · aspeddro · Jun 21, 2026, 01:52 UTC

Refactor code, better error messages

0f16ff56a · aspeddro · Jun 21, 2026, 01:52 UTC

Analysis cmt dump return a string instead a option

a5f8c82e1 · aspeddro · Jun 21, 2026, 01:53 UTC

Update lsp.md

b712f282d · aspeddro · Jun 21, 2026, 02:45 UTC

minor fixes

136c02fec · aspeddro · Jun 21, 2026, 16:26 UTC

minor refactor

0e0b49570 · aspeddro · Jun 30, 2026, 14:04 UTC

fix typo: Unknow -> Unknown

a13340d96 · aspeddro · Jun 30, 2026, 14:07 UTC

code actions: use %todo

82dad0a08 · aspeddro · Jun 30, 2026, 14:16 UTC

Update lsp.md

d313206a8 · aspeddro · Jun 30, 2026, 14:16 UTC

Update lsp.md

23337d4c6 · aspeddro · Jun 30, 2026, 14:33 UTC

lsp.md: fix typos

539d1a6c5 · aspeddro · Jul 01, 2026, 16:05 UTC

Add rescript_language_server.mli

649ab7c7e · aspeddro · Jul 12, 2026, 02:40 UTC

update formatter and lsp.md

3b4cfe36e · aspeddro · Jul 16, 2026, 23:55 UTC

Resolve some TODOs

bd375c5dd · aspeddro · Jul 17, 2026, 00:26 UTC

Restore get_runtime_dir in build_system.ml

7079611a7 · aspeddro · Jul 17, 2026, 01:02 UTC

Resolve todo resolve dep resolution using analysis

4959f72b1 · aspeddro · Jul 17, 2026, 01:22 UTC

Remove signature help setting. Enable by default

987257844 · aspeddro · Jul 17, 2026, 02:00 UTC

Replace command rescript-vscode.go_to_location with native URls

file://name.res#LX,Y

Works in VSCode and Zed!!

7b4cdfc86 · aspeddro · Jul 17, 2026, 02:01 UTC

Update lsp.md

45e230874 · aspeddro · Jul 17, 2026, 02:07 UTC

Restore step ci Make Linux headers visible to musl-gcc

e871beb78 · aspeddro · Jul 17, 2026, 02:20 UTC

Update action.yml

87b1b8787 · aspeddro · Jul 17, 2026, 02:47 UTC

Restore version in action.yml

041bf0856 · aspeddro · Jul 17, 2026, 02:47 UTC

Fix uring install on ci

5568145a8 · aspeddro · Jul 17, 2026, 12:17 UTC

Update lsp.md and add notes.md

a0e32ab2f · aspeddro · Jul 17, 2026, 15:16 UTC

Integrate lsp command into Rewatch

9c999ee19 · aspeddro · Jul 17, 2026, 18:39 UTC

Make binary statically linked

bef996d68 · aspeddro · Jul 25, 2026, 02:32 UTC

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.

5061f2fd3 · aspeddro · Jul 25, 2026, 02:33 UTC

add lsp in COMPILER_SOURCES

1a57d9994 · aspeddro · Jul 25, 2026, 03:12 UTC

fix duplicated diagnostic

201b3e18f · aspeddro · Jul 25, 2026, 03:13 UTC

Update test.ml

22b5f6b6f · aspeddro · Jul 25, 2026, 06:20 UTC

Fix formatter

6e6d0eca2 · aspeddro · Jul 26, 2026, 00:55 UTC

Refactor document store to use incremental text change

6cd1f918a · aspeddro · Jul 26, 2026, 00:56 UTC

Fix neovim bug in test dev

ea637a168 · aspeddro · Jul 26, 2026, 01:11 UTC

Update lsp.md

30b092193 · aspeddro · Jul 31, 2026, 18:02 UTC

Add Document.extension_of_kind

4356d72ee · aspeddro · Jul 31, 2026, 18:22 UTC

test: enable tests on windows using Unix.open_process_args

c65e5d1a4 · aspeddro · Aug 02, 2026, 18:40 UTC

implement test e2e

2863c1c80 · aspeddro · Oct 23, 2026, 14:22 UTC

update yarn.lock

0ee23acf1 · aspeddro · Oct 23, 2026, 14:36 UTC

remove lsp from rust rewatch

45e23a9f2 · aspeddro · Oct 23, 2026, 15:34 UTC

update makefile lsp tests

4935477e4 · aspeddro · Oct 23, 2026, 17:07 UTC

add hover test

646b885bd · aspeddro · Oct 24, 2026, 14:43 UTC

Add more lsp tests

a94e6d448 · aspeddro · Oct 24, 2026, 15:00 UTC

Add full tests

c09834439 · aspeddro · Oct 24, 2026, 22:19 UTC

Move lsp entrypoint to rewatch-ocaml

b13ee8995 · aspeddro · Oct 24, 2026, 22:31 UTC

Fix module shadow

c49c5fb08 · aspeddro · Oct 24, 2026, 22:36 UTC

Remove packages/@rescript/darwin-x64

e42db9ac8 · aspeddro · Oct 24, 2026, 22:37 UTC

Remove rescript_language_server_exe binary from bin.js files

bd51ede0c · aspeddro · Oct 24, 2026, 22:55 UTC

Fix dune runtest

3c213783d · aspeddro · Oct 25, 2026, 22:26 UTC

Restore lsp tests on CI

15a7428f5 · aspeddro · Oct 25, 2026, 22:35 UTC

Restore test-rewatch-rust rule in makefile