Skip to content

Commit

Permalink
Use same color as hover for additional info
Browse files Browse the repository at this point in the history
A bit ugly with wrapping divs
  • Loading branch information
tomv564 committed Nov 26, 2019
1 parent d8f0de6 commit f7714a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 11 additions & 2 deletions phantoms.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ div.content {
div.content p {
margin: 0.2rem;
}
div.content p.additional {
margin-top: 0.7rem;
div.content-additional {
background-color: var(--background);
color: var(--whitish);
margin-bottom: 0.4rem;
}
div.content-additional-inner {
padding: 0.4rem 0.4rem 0.4rem 0.7rem;
background-color: color(var(--foreground) alpha(0.25));
}
div.content-additional p {
margin: 0.2rem 0.2rem 0.2rem 0.2rem;
}
div.toolbar {
padding: 0.2rem 0.7rem 0.2rem 0.7rem;
Expand Down
14 changes: 10 additions & 4 deletions plugin/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def create_phantom(self, view: sublime.View, diagnostic: Diagnostic) -> sublime.

additional_infos = "<br>".join([self.format_diagnostic_related_info(info) for info in diagnostic.related_info])
severity = "error" if diagnostic.severity == DiagnosticSeverity.Error else "warning"
content = message + "<p class='additional'>" + additional_infos + "</p>" if additional_infos else message
markup = self.create_phantom_html(content, severity)
additional_content = "<p>" + additional_infos + "</p>" if additional_infos else ""

markup = self.create_phantom_html(message, severity, additional_content)
return sublime.Phantom(
region,
markup,
Expand Down Expand Up @@ -244,8 +245,12 @@ def navigate(self, href: str) -> None:
file_path = os.path.join(self._base_dir, file_path) if self._base_dir else file_path
self._window.open_file(file_path + ":" + location, sublime.ENCODED_POSITION | sublime.TRANSIENT)

def create_phantom_html(self, content: str, severity: str) -> str:
def create_phantom_html(self, content: str, severity: str, additional: str = "") -> str:
stylesheet = sublime.load_resource("Packages/LSP/phantoms.css")
additional_markup = """<div class="content-additional">
<div class="content-additional-inner">{}</div>
</div>""".format(additional) if additional else ""

return """<body id=inline-error>
<style>{}</style>
<div class="{}-arrow"></div>
Expand All @@ -256,8 +261,9 @@ def create_phantom_html(self, content: str, severity: str) -> str:
<a href="next">↓</a>
</div>
<div class="content">{}</div>
{}
</div>
</body>""".format(stylesheet, severity, severity, content)
</body>""".format(stylesheet, severity, severity, content, additional_markup)

def clear(self) -> None:
if self._last_phantom_set:
Expand Down

0 comments on commit f7714a5

Please sign in to comment.