Skip to content

Commit

Permalink
Merge 9554706 into 25e63ba
Browse files Browse the repository at this point in the history
  • Loading branch information
tomv564 committed Oct 2, 2018
2 parents 25e63ba + 9554706 commit 114e600
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
14 changes: 14 additions & 0 deletions plugin/core/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,19 @@
margin-bottom: 0.5rem;
padding: 0.5rem;
}
.lsp_popup .info {
border-width: 0;
background-color: color(var(--bluish) alpha(0.25));
color: var(--whitish);
margin-bottom: 0.5rem;
padding: 0.5rem;
}
.lsp_popup .hints {
border-width: 0;
background-color: color(var(--bluish) alpha(0.25));
color: var(--whitish);
margin-bottom: 0.5rem;
padding: 0.5rem;
}
'''
37 changes: 16 additions & 21 deletions plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import webbrowser
from html import escape
try:
from typing import List, Optional, Any
assert List and Optional and Any
from typing import List, Optional, Any, Dict
assert List and Optional and Any and Dict
except ImportError:
pass

Expand Down Expand Up @@ -38,6 +38,14 @@ def on_hover(self, point, hover_zone):
_test_contents = [] # type: List[str]


class_for_severity = {
DiagnosticSeverity.Error: 'errors',
DiagnosticSeverity.Warning: 'warnings',
DiagnosticSeverity.Information: 'info',
DiagnosticSeverity.Hint: 'hints'
}


class LspHoverCommand(LspTextCommand):
def __init__(self, view):
super().__init__(view)
Expand Down Expand Up @@ -95,26 +103,13 @@ def format_diagnostic(self, diagnostic):
return "<pre>{}</pre>".format(escape(diagnostic.message, False))

def diagnostics_content(self, diagnostics):
formatted_errors = list(
self.format_diagnostic(diagnostic)
for diagnostic in diagnostics
if diagnostic.severity == DiagnosticSeverity.Error)
by_severity = {} # type: Dict[int, List[str]]
for diagnostic in diagnostics:
by_severity.setdefault(diagnostic.severity, []).append(self.format_diagnostic(diagnostic))
formatted = []
if len(formatted_errors) > 0:
formatted.append("<div class='errors'>")
formatted.extend(formatted_errors)
formatted.append("<a href='{}'>{}</a>".format('code-actions',
'Code Actions'))
formatted.append("</div>")

formatted_warnings = list(
self.format_diagnostic(diagnostic)
for diagnostic in diagnostics
if diagnostic.severity == DiagnosticSeverity.Warning)

if len(formatted_warnings) > 0:
formatted.append("<div class='warnings'>")
formatted.extend(formatted_warnings)
for severity, items in by_severity.items():
formatted.append("<div class='{}'>".format(class_for_severity[severity]))
formatted.extend(items)
formatted.append("<a href='{}'>{}</a>".format('code-actions',
'Code Actions'))
formatted.append("</div>")
Expand Down

0 comments on commit 114e600

Please sign in to comment.