sublime-text-merlin
sublime-text-merlin copied to clipboard
Fix and improve "type at cursor" command; show errors in phantoms
Don't merge this, it's not ready yet! I just wanted to make sure it was on your radar before it's done.
Hi there! I found this package in my preparation to do a bunch of OCaml dev in Sublime. I'm glad it's here :)
However, I found that the "type at cursor" text command didn't seem to work, and the related context menu command was kind of lacking. This PR should provide a better interface for accessing types. While I was doing this, I also moved errors into phantoms to get rid of bottom pop-up altogether.
Here are my changes in action on a sample cat program:
![]()
~~Important caveat: this DOES NOT work properly in the current "stable" version of ST3, since phantoms have a major bug that sometimes causes them to display the incorrect content. However, it does work properly on the latest dev build.~~ UPDATE: A new stable ST3 just got released that fixed this bug.
Remaining to-do
- [x] Figure out if there's a way to limit the width of a phantom - otherwise warnings/errors sometimes run offscreen
- [x] Decide the best way to highlight error/warning regions (currently it's using an underline, but that's sometimes confusing)
- [x] Fix the gutter dot color for warnings
- [x] Add a command to "expand" the currently-displayed type
- [x] General cleanup
I didn't realize it, but this would close #19 I suppose.
That looks very cool! I am tempted to switch to st3 :)
Hey @bluepichu, thank you for taking time to contribute to this project! Let me know when I can start reviewing your changes. :raised_hands:
@cynddl - you can review this whenever you're ready :)
@bluepichu Great work! I made a few cosmetic changes and one fix (https://github.com/cynddl/sublime-text-merlin/commit/3bf022ddb328b4abfd6330b8ab89c97a00ab9972):
- (cosmetic) update HTML string interpolation to Python
"".format()syntax - (cosmetic) rename show_errors and display_errors functions,
- (cosmetic) use
os.path.joininstead of manually concatenating paths, - (fix) the selection under the cursor was not working when the cursor was exactly at the beginning or the end of a word. I relaxed the selection.
I feel like the main file is getting bigger and bigger and would appreciate if we can separate display functionalities (eg. showing phantoms) from commands and event listeners. Maybe by creating a merlin/phantom.py file with all the display-related code. Let me know if you can do that, otherwise I'll see if I have time this week.
Thanks again! 🎉
Hi @cynddl -- looks great! I definitely won't have time for the remainder of this week, so definitely don't wait on me for any restructuring you want to do.