-
Notifications
You must be signed in to change notification settings - Fork 413
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
[merlin] Incoming changes to dune ocaml-merlin
#4217
Comments
Nice summary! For 1 and 2, using relative paths seems like the way to go. For the other problems, do we know why the current system is not enough for cases reported by users? Falling back to the old style merlin files is one option, but maybe there are a couple of simple general features that could be added to Dune, would benefit everyone and would avoid the need for approximate merlin files. |
Regarding section 1 & 2: 👍 Regarding section 4: I don't think I understand what's going on here. Do you know how this happens / can we get a reproduction case? Regarding section 5:
Regarding section 3: where is it? |
About 4:
About 5: However writing a custom Merlin file from scratch in big projects can be a tedious task. My idea was to provide a simple command that would dump a generic merlin file with all |
Understood, thanks for the explanation. |
I investigated item 4 and I would like some input before committing to a solution:
First, a concrete example can be found here. The issue is that Dune generates a configuration for the module Before, in the I gave more thoughts to the possible solutions:
This is the most accurate of the solutions, but also the more complex one: we could scan for Rules stanzas and look at their targets and dependencies to mark them as all being related to the same Merlin configuration. However targets and dependencies are not always
This is the simplest of the solutions, it would work in a lot of cases, and we can document that choice. When asked for the configuration for file
A bad way to solve this issue, but an useful escape hatch for non-standard situations, already in PR#4250.
We could reuse the merging mechanism in the |
I was looking at this example. Here we have a ppx rewriter ( It feels like this could be done differently. For instance, instead of having one rule to produce both the .ml and .c file and one ppx to get the file to type without doing the actual rewriting, one could have:
That would fit better in the system with just as much boilerplate in the dune file. We could talk about such cases in the doc.
What configuration would Dune give to merlin in such a cases? It seems that Dune could pass on the compilation flags and include directories, but what about the preprocessing directive? If the user is using a hand-written rule, it's quite possible that the original source file has syntaxes that merlin won't understand. Can merlin do something in this case? The file might even not parse with the regular OCaml parser.
Agreed. But same remark as above.
Seems reasonable. Commenting preprocessing instructions feels a bit ad-hoc though. If the user resorts to manually editing the merlin file, I would let them comment out the preprocessing instructions.
Agreed. |
For the record, solution 2 has been implemented. Of course it does not gives strong guarantees that the configuration is correct especially regarding PP flags. This is something that could be designed in a future issue. However in simpler case where the users just need to selected a specific source file at build time depending on the context this solution fits perfectly. I am closing this issue since most of the described problems have been solved. |
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
cd
to the "real" directory before starting hacking.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
dune ocaml-merlin
should lowercasethe 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 anyconfiguration 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.
.merlin
file by hand. This can be a daunghtingtask for massive libraries/executables.
module_name.xxxxx.ml
?dune ocaml-merlin
to dump a generic.merlin
file (with commented Preprocessing instructions).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
backfor users with non-standard setups by either:
.merlin
files once by using a specialdune ocaml-merlin --dump-merlin-files
parameter.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.
The text was updated successfully, but these errors were encountered: