Sublime Forum

Click on/hover over region and show overlay text

#1

I recently started to write a Sublime 3 plugin that acts as custom build system for a little programming language that we develop in-house. The plugin executes the compiler of our language (by extending Default.exec.ExecCommand, should that be relevant), parses the errors reported by the compiler and marks the erroneous fragments of the code in the current editor view with squiggly lines and by putting small symbols into the gutter (by using sublime.Region, as one would expect).

Is it possible to make those error regions somehow interactive such that a small overlay box/window is created (next to the mouse cursor) that displays the compiler error message that gave corresponds to the error region? I essentially have the kind of overlays in mind that IDEs such as Eclipse or IntelliJ use to show error messages, API docs, variable types, etc.

According to question https://forum.sublimetext.com/t/semi-transparent-overlay-window/8173/2&hilit=overlay#p45691, overlays were not possible in 2013. Did that change? What about interactive regions?

I would also be fine with a partial solution, for example

  • If only interactive regions are possible, then I would consider displaying the error message in the status bar.
  • If only overlays are possible, then I would consider using a keyboard short-cut to display the original error in the overlay by mapping the current cursor position to the containing error region and then to the correct error message.

EDIT 1: Extending EventListener and using on_selection_modified I was able to “fake” interactive regions by probing whether the cursor (view.sel()[0]) is contained in one of the error regions, and if, I show the corresponding compiler error in the status bar. Is that the best possible way of achieving what I want? I assume that an event bound to the regions would perform better.

0 Likes

#2

Your EDIT 1 is what SublimeLinter is doing currently, and imo it is sufficient for most cases.

However, you are lucky because just yesterday popups where added to the ST API in 3070. See Dev Build 3070 for details. Be careful with not to unintentionally override other plugin’s popups however since only one is possible at a time.

I don’t think you can get hover events, especially on the gutter, however. If you can I’d certainly be interested in how.

0 Likes

#3

Thanks for clarifying things, FichteFoll! Regarding the new popup-functionality, I just started experimenting with it and it works like charm :smiley:. It is great to see the recent progress Sublime made, and I am looking forward to see more features being added.

0 Likes