-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add type insertion and info preview. #15
Conversation
This functionality uses the exist type and info features. Type insertion simply writes the type to the buffer intelligently. Type signatures can be inserted as by calling ":GhcModTypeInsert". Info preview uses vim's preview window to display ":GhcModInfo" persistently. It also allows for several different info's to be displayed at once. The window is opened by calling ":GhcModInfoPreview". The window is closed and erased on ":pclose".
f x = return x I suggest to use |
After ghcmod#type() is called, the relevant area is highlighted, but then we insert the type above it and shift all the code. In the end, the highlight is over the wrong area so we just throw it out.
Yes. I noticed that as well. It's a problem for sure and I've complained upstream. I am still working on how to get ghc-mod to report that information in the first place. As it is right now, this feature works in the sense that it inserts the type that ghc-mod reports. We just need ghc-mod to start reporting full type information. See DanielG/ghc-mod#69. If you feel like it's a net loss then this patch can just sit around until that issue is fixed upsteam. I still use this feature and add the type-class contraints myself as necessary. For simple functions maybe it's not great, but for complicated types I think it's worth it. |
Maybe I misunderstood. Are you suggesting using info() for type insertion? That could work I guess, after some cleaning. |
Ah I remember now. Info() doesn't work at all unless you are using it for top-level symbols. Sometimes you need to constrain types in smaller throwaway functions inside a where clause, for example. Using I don't see why ghc-mod itself wouldn't report the typeclass though. It's just as much a part of the type as anything else. |
Yes, the info command can be used only for top-level symbols... Although there is the type-class problem, I think your features are nice. I'll merge your request. Thank you. |
Add type insertion and info preview.
I have a working a version using Still, maybe if we could intellegently select between the two implementations based on whether or not it's top-level? I'll make a dummy pull-request so you can see what I'm talking about. |
#18, for posterity. |
This functionality uses the exist type and info features. Type insertion simply
writes the type to the buffer intelligently. Type signatures can be inserted as
by calling ":GhcModTypeInsert".
Info preview uses vim's preview window to display ":GhcModInfo" persistently. It
also allows for several different info's to be displayed at once. The window is
opened by calling ":GhcModInfoPreview". The window is closed and erased on
":pclose".