Skip to content

Commit 765ab7e

Browse files
committed
Fix merlin-lib 4.18 compatibility for OCaml 4.14
- inlay_hints.ml: Disable hint_function_params (not available in merlin-lib 4.18) - rename.ml: Use `Buffer scope instead of `Renaming (project-wide renaming not available in merlin-lib 4.18)
1 parent 6012e15 commit 765ab7e

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

ocaml-lsp-server/src/inlay_hints.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ let compute (state : State.t) { InlayHintParams.range; textDocument = { uri }; _
2929
c.hint_pattern_variables)
3030
|> Option.value ~default:false
3131
in
32-
let hint_function_params =
33-
Option.map state.configuration.data.inlay_hints ~f:(fun c ->
34-
c.hint_function_params)
35-
|> Option.value ~default:false
36-
in
3732
Document.Merlin.with_pipeline_exn ~name:"inlay-hints" doc (fun pipeline ->
3833
let start = range.start |> Position.logical
3934
and stop = range.end_ |> Position.logical in
@@ -43,7 +38,6 @@ let compute (state : State.t) { InlayHintParams.range; textDocument = { uri }; _
4338
, stop
4439
, hint_let_bindings
4540
, hint_pattern_variables
46-
, hint_function_params
4741
, not inside_test )
4842
in
4943
let hints = Query_commands.dispatch pipeline command in

ocaml-lsp-server/src/rename.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let rename (state : State.t) { RenameParams.textDocument = { uri }; position; ne
88
| `Other -> Fiber.return (WorkspaceEdit.create ())
99
| `Merlin merlin ->
1010
let command =
11-
Query_protocol.Occurrences (`Ident_at (Position.logical position), `Renaming)
11+
Query_protocol.Occurrences (`Ident_at (Position.logical position), `Buffer)
1212
in
1313
let+ locs, _status = Document.Merlin.dispatch_exn ~name:"rename" merlin command in
1414
let version = Document.version doc in
@@ -22,7 +22,11 @@ let rename (state : State.t) { RenameParams.textDocument = { uri }; position; ne
2222
| "" -> uri
2323
| path -> Uri.of_path path
2424
in
25-
Uri.Map.add_to_list uri edit acc)
25+
let add_to_list key value map =
26+
let existing = Option.value ~default:[] (Uri.Map.find_opt key map) in
27+
Uri.Map.add key (value :: existing) map
28+
in
29+
add_to_list uri edit acc)
2630
in
2731
let edits =
2832
Uri.Map.mapi
@@ -71,7 +75,7 @@ let rename (state : State.t) { RenameParams.textDocument = { uri }; position; ne
7175
if documentChanges
7276
then (
7377
let documentChanges =
74-
Uri.Map.to_list edits
78+
Uri.Map.bindings edits
7579
|> List.map ~f:(fun (uri, edits) ->
7680
let textDocument =
7781
OptionalVersionedTextDocumentIdentifier.create ~uri ~version ()
@@ -81,7 +85,7 @@ let rename (state : State.t) { RenameParams.textDocument = { uri }; position; ne
8185
in
8286
WorkspaceEdit.create ~documentChanges ())
8387
else (
84-
let changes = Uri.Map.to_list edits in
88+
let changes = Uri.Map.bindings edits in
8589
WorkspaceEdit.create ~changes ())
8690
in
8791
workspace_edits

0 commit comments

Comments
 (0)