-
Notifications
You must be signed in to change notification settings - Fork 233
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
Can't go-to-definition in generated file #1761
Comments
Hi @Timmmm , thanks for your report ! This is a long-standing issue: Merlin is told by Dune where to find sources and build files. In a dune project the sources are copied inside the However, it is frequent that users are interested in generated files, so the current behavior is not satisfying. There is a simple workaround however: you can set the generated file to be promoted to the source files. This will make it visible to Merlin. For example, you can have the output of a rule promoted (but removed by (more detail in the documentation) |
The files in the |
If I'm understanding this correctly, that will mean the generated file is in
Yeah that doesn't really follow - as you say my purpose for jumping to the file is not to modify it. I'll try |
Hmm that didn't seem to work. I added
But now it just doesn't even try to run |
Ah I eventually found that it works for |
Ok so However I don't think this is a good solution. Dune doesn't mark |
As I said, I don't think the current situation is satisfying.
Until someone tackles that issue, I think the workaround is the best option. I didn't know that the release profile skipped the promotion, maybe it's only for "until-clean" promotions, maybe you can try removing that. Alternatively, you could configure your flag selection per library or globally: https://dune.readthedocs.io/en/stable/concepts/ocaml-flags.html This way you would be able to build in dev mode. |
I still don't quite understand this. Why is it incorrect to jump to the _build dir? Every other go-to-definition system I've used is quite happy to do so.
Unfortunately that made no difference. I did fix the warnings in dune build so I can now just use that for development at least, but we can't have promote in the code permanently because it breaks dune build --release. With --release it's not just that it doesn't do the promotion; it doesn't run the rule at all so you get compilation errors. Maybe I'll open a bug in the Dune repo... |
Sorry, I edited your message instead of answering it 🤦
We must be careful not to jump to a copy of a source file in the Regardless of the solution that is chosen, this feature requires changing the configuration Dune sends to Merlin.
That's most surprising, I think you should open an issue on Dune, if it is expected behavior they will at least be able to explain it 🙂 |
Ok feedback from the Dune guys: |
I still think promoting files to sources when building on For a real solution we need Dune to communicate to Merlin the path of generated files. (Note that Merlin behaves as intended: it jumps only to sources that are part of the declared |
Is there a way to enable promotion in dev mode and disabled it in release mode though? |
Ah yes, the issue is that I guess you could have two rules and use |
Hi, I am very new to OCaml but I've been working on the Sail compiler which is written in OCaml using VSCode and ocaml-lsp. Generally the LSP works very well, however there is an issue with the generated file
_build/default/src/lib/ast.ml
. Ocaml-lsp seems to know at least something about the types in it, because you can hover them and it shows their types. For example insrc/lib/ast_util.ml
on this line:Nexp_if
is defined in_build/default/src/lib/ast.ml
. If I hoveri1
it says the type isn_constraint
which is correct! However for some reason I cannot ctrl-click / go-to-definition onNexp_if
.If I run
Then it doesn't have
(S .../_build/default/src/lib)
anywhere, though it does have(B .../_build/default/src/lib/.libsail.objs/byte)
.Any idea why this isn't working or how to make it work?
The text was updated successfully, but these errors were encountered: