We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Some servers provide tooltips for ignored scopes
The vscode-json-languageserver provides tooltips for json keys, but the `string` scope is ignored
https://github.com/tomv564/LSP/blob/1836426c85826f20de73e50ab285a948eebbeba4/plugin/hover.py#L21


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugin/hover.py`
Content:
```
1 import mdpopups
2 import sublime
3 import sublime_plugin
4 import webbrowser
5 from html import escape
6 try:
7     from typing import List, Optional, Any, Dict
8     assert List and Optional and Any and Dict
9 except ImportError:
10     pass
11 
12 from .core.configurations import is_supported_syntax
13 from .diagnostics import get_point_diagnostics
14 from .core.registry import session_for_view, LspTextCommand
15 from .core.protocol import Request, DiagnosticSeverity
16 from .core.documents import get_document_position
17 from .core.popups import popup_css, popup_class
18 from .core.settings import client_configs
19 
20 SUBLIME_WORD_MASK = 515
21 NO_HOVER_SCOPES = 'comment, string'
22 
23 
24 class HoverHandler(sublime_plugin.ViewEventListener):
25     def __init__(self, view):
26         self.view = view
27 
28     @classmethod
29     def is_applicable(cls, settings):
30         syntax = settings.get('syntax')
31         return syntax and is_supported_syntax(syntax, client_configs.all)
32 
33     def on_hover(self, point, hover_zone):
34         if hover_zone != sublime.HOVER_TEXT or self.view.is_popup_visible():
35             return
36         self.view.run_command("lsp_hover", {"point": point})
37 
38 
39 _test_contents = []  # type: List[str]
40 
41 
42 class_for_severity = {
43     DiagnosticSeverity.Error: 'errors',
44     DiagnosticSeverity.Warning: 'warnings',
45     DiagnosticSeverity.Information: 'info',
46     DiagnosticSeverity.Hint: 'hints'
47 }
48 
49 
50 class GotoKind:
51 
52     __slots__ = ("lsp_name", "label", "subl_cmd_name")
53 
54     def __init__(self, lsp_name: str, label: str, subl_cmd_name: str) -> None:
55         self.lsp_name = lsp_name
56         self.label = label
57         self.subl_cmd_name = subl_cmd_name
58 
59 
60 goto_kinds = [
61     GotoKind("definition", "Definition", "definition"),
62     GotoKind("typeDefinition", "Type Definition", "type_definition"),
63     GotoKind("declaration", "Declaration", "declaration"),
64     GotoKind("implementation", "Implementation", "implementation")
65 ]
66 
67 
68 class LspHoverCommand(LspTextCommand):
69     def __init__(self, view):
70         super().__init__(view)
71 
72     def is_likely_at_symbol(self, point):
73         word_at_sel = self.view.classify(point)
74         return word_at_sel & SUBLIME_WORD_MASK and not self.view.match_selector(point, NO_HOVER_SCOPES)
75 
76     def run(self, edit, point=None):
77         if point is None:
78             point = self.view.sel()[0].begin()
79         if self.is_likely_at_symbol(point):
80             self.request_symbol_hover(point)
81         point_diagnostics = get_point_diagnostics(self.view, point)
82         if point_diagnostics:
83             self.show_hover(point, self.diagnostics_content(point_diagnostics))
84 
85     def request_symbol_hover(self, point) -> None:
86         session = session_for_view(self.view, point)
87         if session:
88             if session.has_capability('hoverProvider'):
89                 document_position = get_document_position(self.view, point)
90                 if document_position:
91                     if session.client:
92                         session.client.send_request(
93                             Request.hover(document_position),
94                             lambda response: self.handle_response(response, point))
95 
96     def handle_response(self, response: 'Optional[Any]', point) -> None:
97         all_content = ""
98 
99         point_diagnostics = get_point_diagnostics(self.view, point)
100         if point_diagnostics:
101             all_content += self.diagnostics_content(point_diagnostics)
102 
103         all_content += self.hover_content(point, response)
104         all_content += self.symbol_actions_content()
105 
106         _test_contents.clear()
107         _test_contents.append(all_content)  # for testing only
108         self.show_hover(point, all_content)
109 
110     def symbol_actions_content(self):
111         actions = []
112         for goto_kind in goto_kinds:
113             if self.has_client_with_capability(goto_kind.lsp_name + "Provider"):
114                 actions.append("<a href='{}'>{}</a>".format(goto_kind.lsp_name, goto_kind.label))
115         if self.has_client_with_capability('referencesProvider'):
116             actions.append("<a href='{}'>{}</a>".format('references', 'References'))
117         if self.has_client_with_capability('renameProvider'):
118             actions.append("<a href='{}'>{}</a>".format('rename', 'Rename'))
119         return "<p>" + " | ".join(actions) + "</p>"
120 
121     def format_diagnostic(self, diagnostic):
122         if diagnostic.source:
123             return "<pre>[{}] {}</pre>".format(diagnostic.source, escape(diagnostic.message, False))
124         else:
125             return "<pre>{}</pre>".format(escape(diagnostic.message, False))
126 
127     def diagnostics_content(self, diagnostics):
128         by_severity = {}  # type: Dict[int, List[str]]
129         for diagnostic in diagnostics:
130             by_severity.setdefault(diagnostic.severity, []).append(self.format_diagnostic(diagnostic))
131         formatted = []
132         for severity, items in by_severity.items():
133             formatted.append("<div class='{}'>".format(class_for_severity[severity]))
134             formatted.extend(items)
135             formatted.append("<a href='{}'>{}</a>".format('code-actions',
136                                                           'Code Actions'))
137             formatted.append("</div>")
138 
139         return "".join(formatted)
140 
141     def hover_content(self, point, response: 'Optional[Any]') -> str:
142         contents = ["No description available."]
143         if isinstance(response, dict):
144             # Flow returns None sometimes
145             # See: https://github.com/flowtype/flow-language-server/issues/51
146             response_content = response.get('contents')
147             if response_content:
148                 if isinstance(response_content, list):
149                     contents = response_content
150                 else:
151                     contents = [response_content]
152 
153         formatted = []
154         for item in contents:
155             value = ""
156             language = None
157             if isinstance(item, str):
158                 value = item
159             else:
160                 value = item.get("value")
161                 language = item.get("language")
162             if language:
163                 formatted.append("```{}\n{}\n```\n".format(language, value))
164             else:
165                 formatted.append(value)
166 
167         return mdpopups.md2html(self.view, "\n".join(formatted))
168 
169     def show_hover(self, point, contents):
170         mdpopups.show_popup(
171             self.view,
172             contents,
173             css=popup_css,
174             md=False,
175             flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
176             location=point,
177             wrapper_class=popup_class,
178             max_width=800,
179             on_navigate=lambda href: self.on_hover_navigate(href, point))
180 
181     def on_hover_navigate(self, href, point):
182         for goto_kind in goto_kinds:
183             if href == goto_kind.lsp_name:
184                 self.run_command_from_point(point, "lsp_symbol_" + goto_kind.subl_cmd_name)
185                 return
186         if href == 'references':
187             self.run_command_from_point(point, "lsp_symbol_references")
188         elif href == 'rename':
189             self.run_command_from_point(point, "lsp_symbol_rename")
190         elif href == 'code-actions':
191             self.run_command_from_point(point, "lsp_code_actions")
192         else:
193             webbrowser.open_new_tab(href)
194 
195     def run_command_from_point(self, point, command_name):
196         sel = self.view.sel()
197         sel.clear()
198         sel.add(sublime.Region(point, point))
199         self.view.run_command(command_name)
200
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugin/hover.py b/plugin/hover.py
--- a/plugin/hover.py
+++ b/plugin/hover.py
@@ -18,7 +18,6 @@
 from .core.settings import client_configs
 
 SUBLIME_WORD_MASK = 515
-NO_HOVER_SCOPES = 'comment, string'
 
 
 class HoverHandler(sublime_plugin.ViewEventListener):
@@ -71,7 +70,7 @@
 
     def is_likely_at_symbol(self, point):
         word_at_sel = self.view.classify(point)
-        return word_at_sel & SUBLIME_WORD_MASK and not self.view.match_selector(point, NO_HOVER_SCOPES)
+        return word_at_sel & SUBLIME_WORD_MASK
 
     def run(self, edit, point=None):
         if point is None:
@@ -101,11 +100,14 @@
             all_content += self.diagnostics_content(point_diagnostics)
 
         all_content += self.hover_content(point, response)
-        all_content += self.symbol_actions_content()
+        if all_content:
+            all_content += self.symbol_actions_content()
 
         _test_contents.clear()
         _test_contents.append(all_content)  # for testing only
-        self.show_hover(point, all_content)
+
+        if all_content:
+            self.show_hover(point, all_content)
 
     def symbol_actions_content(self):
         actions = []
@@ -139,10 +141,8 @@
         return "".join(formatted)
 
     def hover_content(self, point, response: 'Optional[Any]') -> str:
-        contents = ["No description available."]
+        contents = []  # type: List[Any]
         if isinstance(response, dict):
-            # Flow returns None sometimes
-            # See: https://github.com/flowtype/flow-language-server/issues/51
             response_content = response.get('contents')
             if response_content:
                 if isinstance(response_content, list):
@@ -164,7 +164,10 @@
             else:
                 formatted.append(value)
 
-        return mdpopups.md2html(self.view, "\n".join(formatted))
+        if formatted:
+            return mdpopups.md2html(self.view, "\n".join(formatted))
+
+        return ""
 
     def show_hover(self, point, contents):
         mdpopups.show_popup(

{"golden_diff": "diff --git a/plugin/hover.py b/plugin/hover.py\n--- a/plugin/hover.py\n+++ b/plugin/hover.py\n@@ -18,7 +18,6 @@\n from .core.settings import client_configs\n \n SUBLIME_WORD_MASK = 515\n-NO_HOVER_SCOPES = 'comment, string'\n \n \n class HoverHandler(sublime_plugin.ViewEventListener):\n@@ -71,7 +70,7 @@\n \n     def is_likely_at_symbol(self, point):\n         word_at_sel = self.view.classify(point)\n-        return word_at_sel & SUBLIME_WORD_MASK and not self.view.match_selector(point, NO_HOVER_SCOPES)\n+        return word_at_sel & SUBLIME_WORD_MASK\n \n     def run(self, edit, point=None):\n         if point is None:\n@@ -101,11 +100,14 @@\n             all_content += self.diagnostics_content(point_diagnostics)\n \n         all_content += self.hover_content(point, response)\n-        all_content += self.symbol_actions_content()\n+        if all_content:\n+            all_content += self.symbol_actions_content()\n \n         _test_contents.clear()\n         _test_contents.append(all_content)  # for testing only\n-        self.show_hover(point, all_content)\n+\n+        if all_content:\n+            self.show_hover(point, all_content)\n \n     def symbol_actions_content(self):\n         actions = []\n@@ -139,10 +141,8 @@\n         return \"\".join(formatted)\n \n     def hover_content(self, point, response: 'Optional[Any]') -> str:\n-        contents = [\"No description available.\"]\n+        contents = []  # type: List[Any]\n         if isinstance(response, dict):\n-            # Flow returns None sometimes\n-            # See: https://github.com/flowtype/flow-language-server/issues/51\n             response_content = response.get('contents')\n             if response_content:\n                 if isinstance(response_content, list):\n@@ -164,7 +164,10 @@\n             else:\n                 formatted.append(value)\n \n-        return mdpopups.md2html(self.view, \"\\n\".join(formatted))\n+        if formatted:\n+            return mdpopups.md2html(self.view, \"\\n\".join(formatted))\n+\n+        return \"\"\n \n     def show_hover(self, point, contents):\n         mdpopups.show_popup(\n", "issue": "Some servers provide tooltips for ignored scopes\nThe vscode-json-languageserver provides tooltips for json keys, but the `string` scope is ignored\r\nhttps://github.com/tomv564/LSP/blob/1836426c85826f20de73e50ab285a948eebbeba4/plugin/hover.py#L21\r\n\n", "before_files": [{"content": "import mdpopups\nimport sublime\nimport sublime_plugin\nimport webbrowser\nfrom html import escape\ntry:\n    from typing import List, Optional, Any, Dict\n    assert List and Optional and Any and Dict\nexcept ImportError:\n    pass\n\nfrom .core.configurations import is_supported_syntax\nfrom .diagnostics import get_point_diagnostics\nfrom .core.registry import session_for_view, LspTextCommand\nfrom .core.protocol import Request, DiagnosticSeverity\nfrom .core.documents import get_document_position\nfrom .core.popups import popup_css, popup_class\nfrom .core.settings import client_configs\n\nSUBLIME_WORD_MASK = 515\nNO_HOVER_SCOPES = 'comment, string'\n\n\nclass HoverHandler(sublime_plugin.ViewEventListener):\n    def __init__(self, view):\n        self.view = view\n\n    @classmethod\n    def is_applicable(cls, settings):\n        syntax = settings.get('syntax')\n        return syntax and is_supported_syntax(syntax, client_configs.all)\n\n    def on_hover(self, point, hover_zone):\n        if hover_zone != sublime.HOVER_TEXT or self.view.is_popup_visible():\n            return\n        self.view.run_command(\"lsp_hover\", {\"point\": point})\n\n\n_test_contents = []  # type: List[str]\n\n\nclass_for_severity = {\n    DiagnosticSeverity.Error: 'errors',\n    DiagnosticSeverity.Warning: 'warnings',\n    DiagnosticSeverity.Information: 'info',\n    DiagnosticSeverity.Hint: 'hints'\n}\n\n\nclass GotoKind:\n\n    __slots__ = (\"lsp_name\", \"label\", \"subl_cmd_name\")\n\n    def __init__(self, lsp_name: str, label: str, subl_cmd_name: str) -> None:\n        self.lsp_name = lsp_name\n        self.label = label\n        self.subl_cmd_name = subl_cmd_name\n\n\ngoto_kinds = [\n    GotoKind(\"definition\", \"Definition\", \"definition\"),\n    GotoKind(\"typeDefinition\", \"Type Definition\", \"type_definition\"),\n    GotoKind(\"declaration\", \"Declaration\", \"declaration\"),\n    GotoKind(\"implementation\", \"Implementation\", \"implementation\")\n]\n\n\nclass LspHoverCommand(LspTextCommand):\n    def __init__(self, view):\n        super().__init__(view)\n\n    def is_likely_at_symbol(self, point):\n        word_at_sel = self.view.classify(point)\n        return word_at_sel & SUBLIME_WORD_MASK and not self.view.match_selector(point, NO_HOVER_SCOPES)\n\n    def run(self, edit, point=None):\n        if point is None:\n            point = self.view.sel()[0].begin()\n        if self.is_likely_at_symbol(point):\n            self.request_symbol_hover(point)\n        point_diagnostics = get_point_diagnostics(self.view, point)\n        if point_diagnostics:\n            self.show_hover(point, self.diagnostics_content(point_diagnostics))\n\n    def request_symbol_hover(self, point) -> None:\n        session = session_for_view(self.view, point)\n        if session:\n            if session.has_capability('hoverProvider'):\n                document_position = get_document_position(self.view, point)\n                if document_position:\n                    if session.client:\n                        session.client.send_request(\n                            Request.hover(document_position),\n                            lambda response: self.handle_response(response, point))\n\n    def handle_response(self, response: 'Optional[Any]', point) -> None:\n        all_content = \"\"\n\n        point_diagnostics = get_point_diagnostics(self.view, point)\n        if point_diagnostics:\n            all_content += self.diagnostics_content(point_diagnostics)\n\n        all_content += self.hover_content(point, response)\n        all_content += self.symbol_actions_content()\n\n        _test_contents.clear()\n        _test_contents.append(all_content)  # for testing only\n        self.show_hover(point, all_content)\n\n    def symbol_actions_content(self):\n        actions = []\n        for goto_kind in goto_kinds:\n            if self.has_client_with_capability(goto_kind.lsp_name + \"Provider\"):\n                actions.append(\"<a href='{}'>{}</a>\".format(goto_kind.lsp_name, goto_kind.label))\n        if self.has_client_with_capability('referencesProvider'):\n            actions.append(\"<a href='{}'>{}</a>\".format('references', 'References'))\n        if self.has_client_with_capability('renameProvider'):\n            actions.append(\"<a href='{}'>{}</a>\".format('rename', 'Rename'))\n        return \"<p>\" + \" | \".join(actions) + \"</p>\"\n\n    def format_diagnostic(self, diagnostic):\n        if diagnostic.source:\n            return \"<pre>[{}] {}</pre>\".format(diagnostic.source, escape(diagnostic.message, False))\n        else:\n            return \"<pre>{}</pre>\".format(escape(diagnostic.message, False))\n\n    def diagnostics_content(self, diagnostics):\n        by_severity = {}  # type: Dict[int, List[str]]\n        for diagnostic in diagnostics:\n            by_severity.setdefault(diagnostic.severity, []).append(self.format_diagnostic(diagnostic))\n        formatted = []\n        for severity, items in by_severity.items():\n            formatted.append(\"<div class='{}'>\".format(class_for_severity[severity]))\n            formatted.extend(items)\n            formatted.append(\"<a href='{}'>{}</a>\".format('code-actions',\n                                                          'Code Actions'))\n            formatted.append(\"</div>\")\n\n        return \"\".join(formatted)\n\n    def hover_content(self, point, response: 'Optional[Any]') -> str:\n        contents = [\"No description available.\"]\n        if isinstance(response, dict):\n            # Flow returns None sometimes\n            # See: https://github.com/flowtype/flow-language-server/issues/51\n            response_content = response.get('contents')\n            if response_content:\n                if isinstance(response_content, list):\n                    contents = response_content\n                else:\n                    contents = [response_content]\n\n        formatted = []\n        for item in contents:\n            value = \"\"\n            language = None\n            if isinstance(item, str):\n                value = item\n            else:\n                value = item.get(\"value\")\n                language = item.get(\"language\")\n            if language:\n                formatted.append(\"```{}\\n{}\\n```\\n\".format(language, value))\n            else:\n                formatted.append(value)\n\n        return mdpopups.md2html(self.view, \"\\n\".join(formatted))\n\n    def show_hover(self, point, contents):\n        mdpopups.show_popup(\n            self.view,\n            contents,\n            css=popup_css,\n            md=False,\n            flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,\n            location=point,\n            wrapper_class=popup_class,\n            max_width=800,\n            on_navigate=lambda href: self.on_hover_navigate(href, point))\n\n    def on_hover_navigate(self, href, point):\n        for goto_kind in goto_kinds:\n            if href == goto_kind.lsp_name:\n                self.run_command_from_point(point, \"lsp_symbol_\" + goto_kind.subl_cmd_name)\n                return\n        if href == 'references':\n            self.run_command_from_point(point, \"lsp_symbol_references\")\n        elif href == 'rename':\n            self.run_command_from_point(point, \"lsp_symbol_rename\")\n        elif href == 'code-actions':\n            self.run_command_from_point(point, \"lsp_code_actions\")\n        else:\n            webbrowser.open_new_tab(href)\n\n    def run_command_from_point(self, point, command_name):\n        sel = self.view.sel()\n        sel.clear()\n        sel.add(sublime.Region(point, point))\n        self.view.run_command(command_name)\n", "path": "plugin/hover.py"}], "after_files": [{"content": "import mdpopups\nimport sublime\nimport sublime_plugin\nimport webbrowser\nfrom html import escape\ntry:\n    from typing import List, Optional, Any, Dict\n    assert List and Optional and Any and Dict\nexcept ImportError:\n    pass\n\nfrom .core.configurations import is_supported_syntax\nfrom .diagnostics import get_point_diagnostics\nfrom .core.registry import session_for_view, LspTextCommand\nfrom .core.protocol import Request, DiagnosticSeverity\nfrom .core.documents import get_document_position\nfrom .core.popups import popup_css, popup_class\nfrom .core.settings import client_configs\n\nSUBLIME_WORD_MASK = 515\n\n\nclass HoverHandler(sublime_plugin.ViewEventListener):\n    def __init__(self, view):\n        self.view = view\n\n    @classmethod\n    def is_applicable(cls, settings):\n        syntax = settings.get('syntax')\n        return syntax and is_supported_syntax(syntax, client_configs.all)\n\n    def on_hover(self, point, hover_zone):\n        if hover_zone != sublime.HOVER_TEXT or self.view.is_popup_visible():\n            return\n        self.view.run_command(\"lsp_hover\", {\"point\": point})\n\n\n_test_contents = []  # type: List[str]\n\n\nclass_for_severity = {\n    DiagnosticSeverity.Error: 'errors',\n    DiagnosticSeverity.Warning: 'warnings',\n    DiagnosticSeverity.Information: 'info',\n    DiagnosticSeverity.Hint: 'hints'\n}\n\n\nclass GotoKind:\n\n    __slots__ = (\"lsp_name\", \"label\", \"subl_cmd_name\")\n\n    def __init__(self, lsp_name: str, label: str, subl_cmd_name: str) -> None:\n        self.lsp_name = lsp_name\n        self.label = label\n        self.subl_cmd_name = subl_cmd_name\n\n\ngoto_kinds = [\n    GotoKind(\"definition\", \"Definition\", \"definition\"),\n    GotoKind(\"typeDefinition\", \"Type Definition\", \"type_definition\"),\n    GotoKind(\"declaration\", \"Declaration\", \"declaration\"),\n    GotoKind(\"implementation\", \"Implementation\", \"implementation\")\n]\n\n\nclass LspHoverCommand(LspTextCommand):\n    def __init__(self, view):\n        super().__init__(view)\n\n    def is_likely_at_symbol(self, point):\n        word_at_sel = self.view.classify(point)\n        return word_at_sel & SUBLIME_WORD_MASK\n\n    def run(self, edit, point=None):\n        if point is None:\n            point = self.view.sel()[0].begin()\n        if self.is_likely_at_symbol(point):\n            self.request_symbol_hover(point)\n        point_diagnostics = get_point_diagnostics(self.view, point)\n        if point_diagnostics:\n            self.show_hover(point, self.diagnostics_content(point_diagnostics))\n\n    def request_symbol_hover(self, point) -> None:\n        session = session_for_view(self.view, point)\n        if session:\n            if session.has_capability('hoverProvider'):\n                document_position = get_document_position(self.view, point)\n                if document_position:\n                    if session.client:\n                        session.client.send_request(\n                            Request.hover(document_position),\n                            lambda response: self.handle_response(response, point))\n\n    def handle_response(self, response: 'Optional[Any]', point) -> None:\n        all_content = \"\"\n\n        point_diagnostics = get_point_diagnostics(self.view, point)\n        if point_diagnostics:\n            all_content += self.diagnostics_content(point_diagnostics)\n\n        all_content += self.hover_content(point, response)\n        if all_content:\n            all_content += self.symbol_actions_content()\n\n        _test_contents.clear()\n        _test_contents.append(all_content)  # for testing only\n\n        if all_content:\n            self.show_hover(point, all_content)\n\n    def symbol_actions_content(self):\n        actions = []\n        for goto_kind in goto_kinds:\n            if self.has_client_with_capability(goto_kind.lsp_name + \"Provider\"):\n                actions.append(\"<a href='{}'>{}</a>\".format(goto_kind.lsp_name, goto_kind.label))\n        if self.has_client_with_capability('referencesProvider'):\n            actions.append(\"<a href='{}'>{}</a>\".format('references', 'References'))\n        if self.has_client_with_capability('renameProvider'):\n            actions.append(\"<a href='{}'>{}</a>\".format('rename', 'Rename'))\n        return \"<p>\" + \" | \".join(actions) + \"</p>\"\n\n    def format_diagnostic(self, diagnostic):\n        if diagnostic.source:\n            return \"<pre>[{}] {}</pre>\".format(diagnostic.source, escape(diagnostic.message, False))\n        else:\n            return \"<pre>{}</pre>\".format(escape(diagnostic.message, False))\n\n    def diagnostics_content(self, diagnostics):\n        by_severity = {}  # type: Dict[int, List[str]]\n        for diagnostic in diagnostics:\n            by_severity.setdefault(diagnostic.severity, []).append(self.format_diagnostic(diagnostic))\n        formatted = []\n        for severity, items in by_severity.items():\n            formatted.append(\"<div class='{}'>\".format(class_for_severity[severity]))\n            formatted.extend(items)\n            formatted.append(\"<a href='{}'>{}</a>\".format('code-actions',\n                                                          'Code Actions'))\n            formatted.append(\"</div>\")\n\n        return \"\".join(formatted)\n\n    def hover_content(self, point, response: 'Optional[Any]') -> str:\n        contents = []  # type: List[Any]\n        if isinstance(response, dict):\n            response_content = response.get('contents')\n            if response_content:\n                if isinstance(response_content, list):\n                    contents = response_content\n                else:\n                    contents = [response_content]\n\n        formatted = []\n        for item in contents:\n            value = \"\"\n            language = None\n            if isinstance(item, str):\n                value = item\n            else:\n                value = item.get(\"value\")\n                language = item.get(\"language\")\n            if language:\n                formatted.append(\"```{}\\n{}\\n```\\n\".format(language, value))\n            else:\n                formatted.append(value)\n\n        if formatted:\n            return mdpopups.md2html(self.view, \"\\n\".join(formatted))\n\n        return \"\"\n\n    def show_hover(self, point, contents):\n        mdpopups.show_popup(\n            self.view,\n            contents,\n            css=popup_css,\n            md=False,\n            flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,\n            location=point,\n            wrapper_class=popup_class,\n            max_width=800,\n            on_navigate=lambda href: self.on_hover_navigate(href, point))\n\n    def on_hover_navigate(self, href, point):\n        for goto_kind in goto_kinds:\n            if href == goto_kind.lsp_name:\n                self.run_command_from_point(point, \"lsp_symbol_\" + goto_kind.subl_cmd_name)\n                return\n        if href == 'references':\n            self.run_command_from_point(point, \"lsp_symbol_references\")\n        elif href == 'rename':\n            self.run_command_from_point(point, \"lsp_symbol_rename\")\n        elif href == 'code-actions':\n            self.run_command_from_point(point, \"lsp_code_actions\")\n        else:\n            webbrowser.open_new_tab(href)\n\n    def run_command_from_point(self, point, command_name):\n        sel = self.view.sel()\n        sel.clear()\n        sel.add(sublime.Region(point, point))\n        self.view.run_command(command_name)\n", "path": "plugin/hover.py"}]}