Skip to content

Commit 6f4081c

Browse files
committed
Highlight warnings as yellow in hovers
Fixes sublimelsp#252
1 parent 336496b commit 6f4081c

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

plugin/core/popups.py

+8
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@
2323
margin-bottom: 0.5rem;
2424
padding: 0.5rem;
2525
}
26+
.lsp_popup .warnings {
27+
border-width: 0;
28+
background-color: color(var(--yellowish) alpha(0.25));
29+
color: --whitish;
30+
margin-bottom: 0.5rem;
31+
padding: 0.5rem;
32+
}
33+
2634
'''

plugin/hover.py

+24-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .core.configurations import is_supported_syntax
77
from .core.diagnostics import get_point_diagnostics
88
from .core.clients import LspTextCommand, client_for_view
9-
from .core.protocol import Request
9+
from .core.protocol import Request, DiagnosticSeverity
1010
from .core.documents import get_document_position
1111
from .core.popups import popup_css, popup_class
1212

@@ -76,10 +76,29 @@ def symbol_actions_content(self):
7676
return "<p>" + " | ".join(actions) + "</p>"
7777

7878
def diagnostics_content(self, diagnostics):
79-
formatted = ["<div class='errors'>"]
80-
formatted.extend("<pre>{}</pre>".format(diagnostic.message) for diagnostic in diagnostics)
81-
formatted.append("<a href='{}'>{}</a>".format('code-actions', 'Code Actions'))
82-
formatted.append("</div>")
79+
formatted_errors = list(
80+
"<pre>{}</pre>".format(diagnostic.message)
81+
for diagnostic in diagnostics
82+
if diagnostic.severity == DiagnosticSeverity.Error)
83+
if len(formatted_errors) > 0:
84+
formatted = ["<div class='errors'>"]
85+
formatted.extend(formatted_errors)
86+
formatted.append("<a href='{}'>{}</a>".format('code-actions',
87+
'Code Actions'))
88+
formatted.append("</div>")
89+
90+
formatted_warnings = list(
91+
"<pre>{}</pre>".format(diagnostic.message)
92+
for diagnostic in diagnostics
93+
if diagnostic.severity == DiagnosticSeverity.Warning)
94+
95+
if len(formatted_warnings) > 0:
96+
formatted = ["<div class='warnings'>"]
97+
formatted.extend(formatted_warnings)
98+
formatted.append("<a href='{}'>{}</a>".format('code-actions',
99+
'Code Actions'))
100+
formatted.append("</div>")
101+
83102
return "".join(formatted)
84103

85104
def hover_content(self, point, response):

0 commit comments

Comments
 (0)