codequest-eu / SublimeLinter-contrib-reek

SublimeLinter 3 plugin for Ruby, using reek.
MIT License
8 stars 9 forks source link

Tooltips #2

Closed dazza-codes closed 8 years ago

dazza-codes commented 8 years ago

Add tooltips for reek.

Related to https://github.com/SublimeLinter/SublimeLinter3/issues/178

dazza-codes commented 8 years ago

See also

kruszczynski commented 8 years ago

@darrenleeweber Thanks for the suggestion however I think this feature belongs to SublimeLinter3 repo and from what you linked they are already working on it. Once SublimeLinter gets this feature this plugin will probably support it out of the box.

dazza-codes commented 8 years ago

OK, no problem. FYI, I'm finding this snippet useful at lines 409-421 of sublimelinter.py:

                    # show_popup(self, content, flags = HTML,
                    #            location = -1, max_width = 320, max_height = 240,
                    #            on_navigate = None, on_hide = None)
                    import string, re
                    pat = r'\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^%s\s]|/)))'
                    pat = pat % re.escape(string.punctuation)
                    http_regex = re.compile(pat)
                    style = '<style>body { padding: 5px } html { background-color: orange }</style>'
                    content = '<div class="content">' + '<br>'.join(line_errors) + '</div>'
                    content = http_regex.sub(r'<a href="\1">\1</a>', content)
                    view.show_popup(style + content, location=-2, max_width=1000, max_height = 300,
                                    on_navigate=self.on_navigate, on_hide=None)
                    sublime.set_timeout_async(view.hide_popup, 5000)

This provides a temporary popup that allows clicking on the reek link for more information.

It requires an additional method too:

    def on_navigate(self, link):
        import webbrowser
        webbrowser.open_new_tab(link)
dazza-codes commented 8 years ago

See also https://github.com/SublimeLinter/SublimeLinter3/pull/450

kruszczynski commented 8 years ago

Looks cool!