Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "ocaml-variants.5.4.0+trunk"
ocaml-compiler: "5.4"

# Remove this pin once a compatible version of Merlin has been released
- name: Pin dev Merlin
run: opam --cli=2.1 pin --with-version=5.6-504 https://github.com/voodoos/merlin.git#504-rebase
run: opam --cli=2.1 pin --with-version=5.6-504 https://github.com/voodoos/merlin.git#main

- name: Build and install dependencies
run: opam install .
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "ocaml-variants.5.4.0+trunk"
ocaml-compiler: "5.4"

- name: Set git user
run: |
Expand All @@ -90,7 +90,7 @@ jobs:

# Remove this pin once a compatible version of Merlin has been released
- name: Pin dev Merlin
run: opam --cli=2.1 pin --with-version=5.6-504 https://github.com/voodoos/merlin.git#504-rebase
run: opam --cli=2.1 pin --with-version=5.6-504 https://github.com/voodoos/merlin.git#main

- name: Install dependencies
run: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased

## Fixes

- Fallback on `.merlin` configuration if no `dune-project` file is found and if
`dot-merlin-reader` is installed. (#1563, fixes #1522)

# 1.24.0

## Features
Expand Down
15 changes: 9 additions & 6 deletions ocaml-lsp-server/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ module Cli = Lsp.Cli
let () =
Printexc.record_backtrace true;
let version = ref false in
let read_dot_merlin = ref false in
let prefer_dot_merlin = ref false in
let arg = Lsp.Cli.Arg.create () in
let spec =
[ "--version", Arg.Set version, "print version"
; ( "--fallback-read-dot-merlin"
, Arg.Set read_dot_merlin
, "read Merlin config from .merlin files. The `dot-merlin-reader` package must be \
installed" )
, Arg.Set prefer_dot_merlin
, "deprecated, same as --prefer-dot-merlin" )
; ( "--prefer-dot-merlin"
, Arg.Set prefer_dot_merlin
, "always read Merlin config from existing .merlin files. \
The `dot-merlin-reader` package must be installed" )
]
@ Cli.Arg.spec arg
in
let usage =
"ocamllsp [ --stdio | --socket PORT | --port PORT | --pipe PIPE ] [ \
--clientProcessId pid ]"
--clientProcessId pid ] [ --prefer-dot-merlin ]"
in
Arg.parse spec (fun _ -> raise @@ Arg.Bad "anonymous arguments aren't allowed") usage;
let channel =
Expand All @@ -37,7 +40,7 @@ let () =
let module Exn_with_backtrace = Stdune.Exn_with_backtrace in
match
Exn_with_backtrace.try_with
(Ocaml_lsp_server.run channel ~read_dot_merlin:!read_dot_merlin)
(Ocaml_lsp_server.run channel ~prefer_dot_merlin:!prefer_dot_merlin)
with
| Ok () -> ()
| Error exn ->
Expand Down
6 changes: 3 additions & 3 deletions ocaml-lsp-server/src/merlin_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module Dot_protocol_io =
let write t x = write t [ x ]
end)

let should_read_dot_merlin = ref false
let prefer_dot_merlin = ref false

type db =
{ running : (string, entry) Table.t
Expand Down Expand Up @@ -298,13 +298,13 @@ let config (t : t) : Mconfig.t Fiber.t =
t.entry <- Some entry
in
let* () = Fiber.return () in
if !should_read_dot_merlin
if !prefer_dot_merlin
then Fiber.return (Mconfig.get_external_config t.path t.initial)
else (
match find_project_context t.directory with
| None ->
let+ () = destroy t in
t.initial
Mconfig.get_external_config t.path t.initial
| Some (ctx, config_path) ->
let* entry = get_process t.db ~dir:ctx.process_dir in
let* () =
Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/merlin_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Import

type t

val should_read_dot_merlin : bool ref
val prefer_dot_merlin : bool ref
val config : t -> Mconfig.t Fiber.t
val destroy : t -> unit Fiber.t

Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -988,10 +988,10 @@ let run_in_directory =
fun () -> if Sys.win32 then for_windows else run_in_directory
;;

let run channel ~read_dot_merlin () =
let run channel ~prefer_dot_merlin () =
Merlin_utils.Lib_config.set_program_name "ocamllsp";
Merlin_utils.Lib_config.System.set_run_in_directory (run_in_directory ());
Merlin_config.should_read_dot_merlin := read_dot_merlin;
Merlin_config.prefer_dot_merlin := prefer_dot_merlin;
Unix.putenv "__MERLIN_MASTER_PID" (string_of_int (Unix.getpid ()));
Lev_fiber.run ~sigpipe:`Ignore (fun () ->
let* input, output = stream_of_channel channel in
Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/ocaml_lsp_server.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val run : Lsp.Cli.Channel.t -> read_dot_merlin:bool -> unit -> unit
val run : Lsp.Cli.Channel.t -> prefer_dot_merlin:bool -> unit -> unit

module Diagnostics = Diagnostics
module Version = Version
Expand Down
Loading