feat(merlin): allow multiple configurations per file - #15493
Conversation
|
How is this going to work on the merlin side? The client is going to flip between the two configs? |
|
My plan was to add a new protocol directive in Merlin to query the multiple configurations per file, so that we could flip between each at will / select a default. I've got a working prototype which seems to work well, and I'm curious about your take? |
|
I find it hard it to imagine needing to switch the configs outside of some |
|
@rgrinberg this is more relevant to the case of single context universal libraries. Let me illustrate it with an example: (library
(name foo)
(libraries promise)
(melange.libraries promise.js))In the case above, assuming both libraries expose a top-level When the editor is in OCaml mode, go-to-definition should find the OCaml library; conversely, in Melange mode, it should jump to the |
|
For goto definition, the lsp protocol is allowed to return more than one result. So I would expect it to just return both locations to and allow the user to choose. So it should still not be necessary to switch between modes. |
|
what about type definitions, etc? i think my point is that, with single context, there can essentially be 2 very distinct libraries with the same name, different preprocessing, different library dependencies, etc. I'm not tied to this specific approach, but I couldn't think of a way to express all of that (incl. pps) in a way that finds the "common" diagnostics. What am I missing? |
|
Type definitions are allowed to return more than on result as well. It is true that the underlying libraries can be entirely different, but I'm arguing that a user should see a unified front:
To summarize, there's not too many explicit backend selection opportunities for the user in such a workflow. There's still plenty going on under the hood automatically, but it's not a flag that the user has to toggle all the time. |
|
Interesting -- I'll take this away and think about it.
Maybe I'm mixing things up -- what responsibilities should Dune have in this case? e.g. How do I express that 2 different PPX generate different code according to the compilation mode? |
|
As I mentioned, my comments aren't directly relevant to this PR. Something similar to what is done here is needed regardless of what is presented to the user. My comments are more relevant to the protocol lsp and Merlin use to talk to dune, and how well equipped are Merlin and Lsp themselves to handle such a multi modal setup. |
|
OK sorry, I think I just misunderstood a lot of what you were saying. Let me try again:
|
8a825df to
863ea62
Compare
Adds expected-failure cram coverage for mode-specific Merlin lookup and missing Melange configurations in mixed-mode libraries. Related to #15493. Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
863ea62 to
58ba73b
Compare
breaks out just the config part from #14821