Khady / merlin-eldoc

Type and doc on hover for OCaml and Reason in emacs
GNU General Public License v3.0
43 stars 3 forks source link

Display type structure instead of only type name #20

Closed loxs closed 6 years ago

loxs commented 6 years ago

When you hover over a record variable, it shows something like:

Module.record_name

Instead, it would be better if we get something like

type record_name = {
    ModuleName.record_field; 
    ...
}

Sometimes I actually do get this (what I request), but only in some contexts like in function heads, which IMO is not enough. I am forced to "go to definition" too often

It happens with other types as well, but it's most annoying with records so far.

Khady commented 6 years ago

This is a deliberate behavior. I was considering that if one wants to see more details about the type, one would call merlin by hand. But it could be adjusted.

When the type of a value is requested using merlin-type-enclosing, It shows the most abstract version of the type. This is what is done by merlin-eldoc.

Merlin offers a mechanism to see a non abstract version of the type. By calling merlin-type-enclosing multiple times in a row on the same value, it goes down in the abstraction level and shows more information.

It is possible to have something in merlin-eldoc which would show non abstract types. The question is how to control it.

loxs commented 6 years ago

Hm, I didn't know about the multiple invocations of Merlin. This certainly will make my life easier a lot.

I don't know about the implications of "always go to the deepest level". To my newbie self, this sounds quite nice, as I still don't have lots of experience and I haven't encountered a place where I wouldn't want that.

Now, if there is some way to do your last suggestion, that would be perfect, but I'm not sure how would it work. How would you activate merlin-eldoc multiple times? Move one character within the same value and wait some more? That would be nicer than pressing the combination for merlin-type-enclosing one more time for sure... though I don't know about values which are only one char.