ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.59k stars 233 forks source link

emacs: module found in several sources #390

Open ghost opened 9 years ago

ghost commented 9 years ago

I'm using Emacs and commit 45cd420ec98523ced2b5b12c4f47177306a874c4 from trunk.

When typing C-c C-l to go to the definition of a module, I sometimes obtain the following message:

if: Several source files in your path have the same name, and merlin doesn't know which is the right one: /home/user/.opam/4.02.1/lib/lablgtk2/gSourceView2.mli, /home/user/.opam/lib/lablgtk2/gSourceView2.ml

For instance, the following code, along with a .merlin file containing PKG lablgtk2, produces the previous message if I try C-c C-l when the cursor is on GSourceView2:

let _ = let v = GSourceView2.source_view in ()

The message is informative, but I don't see an obvious way to avoid it. Is this expected to happen? If so, may I suggest to simply choose one of the files in this case, possibly warning the user?

More precisely, it seems to me that when there are exactly two sources with same paths, and both names coincide except for the .ml/.mli extension, choosing either file would be a useful approach. Or even in the more general case, as long as there is some warning message, choosing the first file among several (possibly requiring a confirmation, such as "type y to confirm") could be more useful than choosing none of them.

trefis commented 9 years ago

Hi!

I got that message a few times as well, but I noticed it only happens when cmt[i] files are missing (otherwise merlin will use information found in the cmt to decide which file to look at). This particular case could probably be improved, I'll see what I can do.

I don't like the "choose the first" one, it used to work that way in the past or rather it used to not work that way in the past. The problem seems trivial here, but on big codebases you might have several foo.ml files and arbitrarily choosing between them is not a good solution.

I like the idea of asking user feedback in these situations however, I might implement it (might, because implementing it requires writing a bunch of elisp and VimL, which I'd rather not do).

ghost commented 9 years ago

Thank you, it's very likely that I have cmt[i] files missing, I already had some "could not find annotation files" errors a few times.

I've already seen major improvements in the error messages lately (much more descriptive messages, which help find out the causes), and since this one in particular is not supposed to happen often anyway, indeed it's probably worth not spending much time on.

Thanks for the good work!