Repository: sublimelsp/LSP

Issue:
How can I change the color of this?
**Is your feature request related to a problem? Please describe.**
I didn't find anything in your documentation to change this part in white, or maybe I am blind?
It's annoying because it's unreadable, I would like to keep the background yellow for the warnings.

![unreadable](https://github.com/sublimelsp/LSP/assets/22882318/d322392d-e2f6-4b30-b25f-29c57ba19909)



Here is my mdpopups.css file:
```css
html.dark {
    background-color: #252525;
    color: #9f9f9f;
}

.dark .mdpopups .highlight {
    background-color: #0f0f0f;
}

html.light {
    background-color: #e5e5e5;
    color: #666666;
}

.light .mdpopups .highlight {
    background-color: #fff;
}

html {
    --mdpopups-font-mono: "Operator Mono Book";
}

.errors a,
.warnings a {
    display: block;
    color: #010192;
    margin-top: 0.5rem;
}

.lsp_popup .errors {
    border-width: 0;
    background-color: #fd3434;
    color: #0f0f0f;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
}

.lsp_popup .warnings {
    border-width: 0;
    background-color: #feff60;
    color: #0f0f0f;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
}

.lsp_popup .info {
    border-width: 0;
    background-color: #00bfff;
    color: #0f0f0f;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
}

.lsp_popup .hints {
    border-width: 0;
    background-color: #f8f8f8;
    color: #0f0f0f;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
}


``` 

**Describe the solution you'd like**
Add an option to be able to modify this color if possible.




Thank you very much and again for your hard work 🙏.



Discussion:
I don't think you can. It's hardcoded currently
https://github.com/sublimelsp/LSP/blob/346599a4fd00ba373c6b67f71e6fe41d3366e2a0/plugin/core/views.py#L998-L1007

This code should be replaced with a CSS class and the color moved into `popups.css`. Then you could adjust it via mdpopups.css.

Resolving patch:
diff --git a/plugin/core/views.py b/plugin/core/views.py
--- a/plugin/core/views.py
+++ b/plugin/core/views.py
@@ -980,39 +980,33 @@ def _format_diagnostic_related_info(
     )
 
 
-def _with_color(text: str, hexcolor: str) -> str:
-    return '<span style="color: {};">{}</span>'.format(hexcolor, text2html(text))
+def _html_element(name: str, text: str, class_name: Optional[str] = None, escape: bool = True) -> str:
+    return '<{0}{2}>{1}</{0}>'.format(
+        name,
+        text2html(text) if escape else text,
+        ' class="{}"'.format(text2html(class_name)) if class_name else ''
+    )
 
 
 def format_diagnostic_for_html(config: ClientConfig, diagnostic: Diagnostic, base_dir: Optional[str] = None) -> str:
-    formatted = [
-        '<pre class="',
-        DIAGNOSTIC_SEVERITY[diagnostic_severity(diagnostic) - 1][1],
-        '">',
-        text2html(diagnostic["message"])
-    ]
+    html = _html_element('span', diagnostic["message"])
     code = diagnostic.get("code")
     source = diagnostic.get("source")
     if source or code is not None:
-        formatted.append(" ")
-    if source:
-        formatted.append(_with_color(source, "color(var(--foreground) alpha(0.6))"))
-    if code is not None:
-        formatted.append(_with_color("(", "color(var(--foreground) alpha(0.6))"))
-        code_description = diagnostic.get("codeDescription")
-        if code_description:
-            formatted.append(make_link(code_description["href"], str(code)))
-        else:
-            formatted.append(_with_color(str(code), "color(var(--foreground) alpha(0.6))"))
-        formatted.append(_with_color(")", "color(var(--foreground) alpha(0.6))"))
+        meta_info = ""
+        if source:
+            meta_info += text2html(source)
+        if code is not None:
+            code_description = diagnostic.get("codeDescription")
+            meta_info += "({})".format(
+                make_link(code_description["href"], str(code)) if code_description else text2html(str(code)))
+        html += " " + _html_element("span", meta_info, class_name="color-muted", escape=False)
     related_infos = diagnostic.get("relatedInformation")
     if related_infos:
-        formatted.append('<pre class="related_info">')
-        formatted.append("<br>".join(_format_diagnostic_related_info(config, info, base_dir)
-                                     for info in related_infos))
-        formatted.append("</pre>")
-    formatted.append("</pre>")
-    return "".join(formatted)
+        info = "<br>".join(_format_diagnostic_related_info(config, info, base_dir) for info in related_infos)
+        html += '<br>' + _html_element("pre", info, class_name="related_info", escape=False)
+    severity_class = DIAGNOSTIC_SEVERITY[diagnostic_severity(diagnostic) - 1][1]
+    return _html_element("pre", html, class_name=severity_class, escape=False)
 
 
 def format_code_actions_for_quick_panel(
diff --git a/plugin/goto_diagnostic.py b/plugin/goto_diagnostic.py
--- a/plugin/goto_diagnostic.py
+++ b/plugin/goto_diagnostic.py
@@ -282,7 +282,7 @@ def preview(self, value: Optional[Tuple[int, Diagnostic]]) -> Union[str, sublime
         if scheme == "file":
             self._preview = open_location(session, self._get_location(diagnostic), flags=sublime.TRANSIENT)
             base_dir = project_base_dir(map(Path, self.window.folders()), Path(path))
-        return diagnostic_html(self.view, session.config, truncate_message(diagnostic), base_dir)
+        return diagnostic_html(session.config, truncate_message(diagnostic), base_dir)
 
     def _get_location(self, diagnostic: Diagnostic) -> Location:
         return diagnostic_location(self.parsed_uri, diagnostic)
@@ -301,8 +301,7 @@ def open_location(session: Session, location: Location, flags: int = 0, group: i
     return session.window.open_file(file_name, flags=flags | sublime.ENCODED_POSITION, group=group)
 
 
-def diagnostic_html(view: sublime.View, config: ClientConfig, diagnostic: Diagnostic,
-                    base_dir: Optional[Path]) -> sublime.Html:
+def diagnostic_html(config: ClientConfig, diagnostic: Diagnostic, base_dir: Optional[Path]) -> sublime.Html:
     content = format_diagnostic_for_html(
         config, truncate_message(diagnostic), None if base_dir is None else str(base_dir))
     return sublime.Html('<style>{}</style><div class="diagnostics {}">{}</div>'.format(


Test patch: