Exemple #1
0
    def on_modified_async(self, view):
        if not is_dlang(view.settings().get('syntax')) or settings.get(
                'dcd_calltip_disable') or Server.instance is None:
            return

        point = view.sel()[0].begin()
        trigger = view.substr(point - 1)
        if trigger == '(' or trigger == ',':
            completions_type, completions = type(self).get_completions(
                view, point)
            if completions_type == 'calltips':
                # Limit the popup window's height
                max_height_in_dip = settings.get(
                    'dcd_calltip_popup_max_height') * view.line_height()
                # Base the popup window's width on the longest line to show
                width_in_dip = (
                    4 + reduce(max, map(lambda line: len(line),
                                        completions))) * view.em_width()

                view.show_popup('<br>'.join(completions),
                                sublime.COOPERATE_WITH_AUTO_COMPLETE
                                | sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                                location=point,
                                max_width=width_in_dip,
                                max_height=max_height_in_dip)
        if not view.settings().get('auto_match_enabled') and trigger == ')':
            view.hide_popup()
Exemple #2
0
    def on_hover(self, view, point, hover_zone):
        if not is_dlang(
                view.settings().get('syntax')) or Server.instance is None:
            return

        if hover_zone == sublime.HOVER_TEXT:
            doc = type(self).get_documentation(view, point)
            if doc is None:
                return

            # Limit the popup window's height
            max_height_in_dip = settings.get(
                'dcd_documentation_popup_max_height') * view.line_height()
            # Base the popup window's width on the longest line to show
            width_in_dip = (
                4 + reduce(max, map(lambda line: len(line),
                                    doc.splitlines()))) * view.em_width()

            # Translate whitespace to HTML
            #   newline -> break tag
            #   space   -> space entity
            #   tab     -> 4 space entities
            doc = doc.replace('\n', '<br>').replace(' ', '&nbsp;').replace(
                '\t', '&nbsp;&nbsp;&nbsp;&nbsp;')

            view.show_popup(doc,
                            flags=sublime.COOPERATE_WITH_AUTO_COMPLETE
                            | sublime.HIDE_ON_MOUSE_MOVE_AWAY,
                            location=point,
                            max_width=width_in_dip,
                            max_height=max_height_in_dip)
Exemple #3
0
    def on_query_completions(self, view, prefix, locations):
        if not is_dlang(
                view.settings().get('syntax')) or Server.instance is None:
            return

        point = locations[0] - len(prefix)
        if (view.substr(point) != '.'):
            point = locations[0]

        completions_type, completions = type(self).get_completions(view, point)
        if completions_type == 'identifiers':
            return ([self.parse_identifiers(line)
                     for line in completions], sublime.INHIBIT_WORD_COMPLETIONS
                    | sublime.INHIBIT_EXPLICIT_COMPLETIONS)
        else:
            return
Exemple #4
0
 def is_applicable(cls, settings):
     return is_dlang(settings.get('syntax'))
Exemple #5
0
 def is_enabled(self):
     return is_dlang(
         self.view.settings().get('syntax')) and Server.instance is not None