sublime-text-merlin icon indicating copy to clipboard operation
sublime-text-merlin copied to clipboard

Fix and improve "type at cursor" command; show errors in phantoms

Open bluepichu opened this issue 8 years ago • 6 comments
trafficstars

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:

New type command demo

~~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

bluepichu avatar Sep 03 '17 20:09 bluepichu

I didn't realize it, but this would close #19 I suppose.

bluepichu avatar Sep 13 '17 22:09 bluepichu

That looks very cool! I am tempted to switch to st3 :)

let-def avatar Sep 14 '17 11:09 let-def

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 avatar Sep 17 '17 16:09 cynddl

@cynddl - you can review this whenever you're ready :)

bluepichu avatar Sep 24 '17 20:09 bluepichu

@bluepichu Great work! I made a few cosmetic changes and one fix (https://github.com/cynddl/sublime-text-merlin/commit/3bf022ddb328b4abfd6330b8ab89c97a00ab9972):

  1. (cosmetic) update HTML string interpolation to Python "".format() syntax
  2. (cosmetic) rename show_errors and display_errors functions,
  3. (cosmetic) use os.path.join instead of manually concatenating paths,
  4. (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! 🎉

cynddl avatar Sep 25 '17 10:09 cynddl

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.

bluepichu avatar Sep 27 '17 21:09 bluepichu