Repository navigation
Experimental ReScript Language Server in OCaml #8425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
28020ee
6c3b7b0
46e18ef
4f3d55f
eedb5d9
ae00b14
a6d5a95
51b3d2f
956b7ef
df1ec78
d677748
51aea94
963d40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes analysis prefer the runtime installed in the project over the compiler-local runtime. Previously, resolving The resolver now searches the project and its ancestor directories first, including the This is not a complete Node/Deno/pnpm module resolver; it extends the existing package-directory lookup. The explicit Module resolution searches each directory and its ancestors for:
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,49 @@ | ||
| let ( /+ ) = Filename.concat | ||
|
|
||
| let rec resolve_node_module_path ~start_path name = | ||
| if name = "@rescript/runtime" then | ||
| (* Hack: we need a reliable way to resolve modules in monorepos. *) | ||
| Some (Runtime_package.get_path ()) | ||
| let package_path name = | ||
| let scope = Filename.dirname name in | ||
| let name = Filename.basename name in | ||
| match scope.[0] with | ||
| | '@' -> scope /+ name | ||
| | _ -> name | ||
|
|
||
| let resolve_deno_pnpm ~start_path name = | ||
| let create_path folder = | ||
| start_path /+ "node_modules" /+ folder /+ "node_modules" | ||
| /+ package_path name | ||
| in | ||
| let deno = create_path ".deno" in | ||
| let pnpm = create_path ".pnpm" in | ||
| match (Files.if_exists deno, Files.if_exists pnpm) with | ||
| | Some deno, None -> Some deno | ||
| | None, Some pnpm -> Some pnpm | ||
| | Some deno, Some pnpm -> | ||
| failwith | ||
| (Printf.sprintf | ||
| "Failed to resolve path for %s. Conflict: two directories found. one \ | ||
| for Deno (%s) and one for pnpm (%s)." | ||
| name deno pnpm) | ||
| | _ -> None | ||
|
|
||
| let rec resolve_from_node_modules ~start_path name = | ||
| let path = start_path /+ "node_modules" /+ package_path name in | ||
| if Files.exists path then Some path | ||
| else | ||
| let scope = Filename.dirname name in | ||
| let name = Filename.basename name in | ||
| let name = | ||
| match scope.[0] with | ||
| | '@' -> scope /+ name | ||
| | _ -> name | ||
| in | ||
| let path = start_path /+ "node_modules" /+ name in | ||
| if Files.exists path then Some path | ||
| else if Filename.dirname start_path = start_path then None | ||
| else resolve_node_module_path ~start_path:(Filename.dirname start_path) name | ||
| match resolve_deno_pnpm ~start_path name with | ||
| | Some p -> Some p | ||
| | None -> | ||
| if Filename.dirname start_path = start_path then None | ||
| else | ||
| resolve_from_node_modules ~start_path:(Filename.dirname start_path) name | ||
|
|
||
| let resolve_node_module_path ~start_path name = | ||
| match resolve_from_node_modules ~start_path name with | ||
| | Some path -> Some path | ||
| | None | ||
| when name = Runtime_package.name | ||
| && Files.exists (Runtime_package.get_path ()) -> | ||
| (* Compiler-local fallback for development builds where the runtime package | ||
| is not installed in the target workspace. Real project installs must win | ||
| so LSP definition locations point at the workspace's node_modules. *) | ||
| Some (Runtime_package.get_path ()) | ||
| | None -> None |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - Add an experimental ReScript language server bundled with the compiler, available | ||
| through `rescript lsp --stdio`. It reuses compiler analysis for hover, | ||
| completion, navigation, rename, diagnostics, formatting, and code actions. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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’sppx_expectdependency pulls in Jane Street PPXs whose versions compatible with thatppxlibrequire OCaml 5.3 or newer.