Skip to content

[merlin] Incoming changes to dune ocaml-merlin #4217

@voodoos

Description

@voodoos

The disposal of .merlin based Merlin configuration was a major change in Dune 2.8 and issues appeared in some untested setups. This issue summarize these problems with known workarounds and candidate solutions. Most of these should be fixed for Dune 2.9.

✅ 1. Dune and Merlin disagree on paths when workspace is in a symlinked folder

  • Workaround: cd to the "real" directory before starting hacking.
  • Solution: exchange paths relative to the CWD of dune ocaml-merlin
    instead of absolute paths.

✅ 2. On Windows Dune and Merlin disagree with how absolute path should look like

Which case ? forward or backward slashes ? etc. That means upgrading to Dune 2.8
breaks Windows setup using both Merlin and Ocaml-LSP

  • Workaround: No easy workaround
  • Solution: on Windows (and Cygwin) dune ocaml-merlin should lowercase
    the paths before comparing them. Also using relatives paths as for issue 1
    should make the process more robust.

☑️ 4. Now that each module has a precise configuration, files must bear a module name

[ocaml/merlin#1262]

Files with an ill-formed module name like mymodule.foo.ml do not have any
configuration loaded. Previously Merlin would always load the generic
configuration for the whole directory, including for source files which does not
reflect a valid module name.

  • Workaround: write a .merlin file by hand. This can be a daunghting
    task for massive libraries/executables.
  • Possible solutions:
    1. Keep track of Dune copy rules to know the module name (I don't know if that is possible) ?
    2. ✅ Decide of a file naming convention for that case: module_name.xxxxx.ml ?
    3. Add a command line parameter for dune ocaml-merlin to dump a generic
      .merlin file (with commented Preprocessing instructions).
    4. Always generate an additional generic configuration that is given to
      Merlin if the filename does not match any known module.

✅ 5. Merlin files

[#4209; #4169]

I feel like in any case we should have a possibility to have .merlin back
for users with non-standard setups by either:

  1. Giving the ability to extract .merlin files once by using a special dune ocaml-merlin --dump-merlin-files parameter.
  2. Or adding an option to the dune-project file to enable approximate .merlin
    files promotion as before.

CC @rgrinberg @jeremiedimino @emillon @trefis

For item 4 (not-a-module-name) I am in favour of solution iv and for item 5 (merlin-files) I am in favor of solution 1, dumping a file with merged configurations (the same as the generic configuration that would be generated for 4.iv) and commented preprocessing directives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions