Repository: sublimelsp/LSP

Issue:
Add ability to hide diagnostics on hover
There is a quite big diagnostic window appears on hover. 
![Screenshot from 2021-07-20 05-54-15](https://user-images.githubusercontent.com/6022888/126251450-c75cd5fb-c13e-4452-8ae3-4e8b8a9f5075.png)

But there is no setting to disable/hide it. Could you kindly add it? Something like "show_hover_diagnostics_severity_level". Or can you point me to line of code where it called, so i can override it?


Discussion:
But the `show_diagnostics_severity_level` setting should be affecting the popup too. If you set it to 3 so that `hint` severity is not reported then the diagnostic should not show up in the popup either.

(From the color of the diagnostic I'm assuming it's a "hint" diagnostic)
Yes it is hint, but  `show_diagnostics_severity_level` doesn't affect it. It only removes circles near line numbers and underlines near variables. I already set it to 3, and as you see circles and underlines are disappears, but on hover we still see hints.
That's not how it's supposed to work and not how it works here. Did you try restarting ST? And also, are you on ST4?
Yes, i am on ST4, version: 4113 linux x64
And i restarted ST several times. There is no errors in console.

Also that's my LSP settings, but this hints displayed even if i set `"show_diagnostics_severity_level": 0,`
![Selection_030](https://user-images.githubusercontent.com/6022888/126294477-c4a831a3-e3ce-4d5d-9caf-638d5c813e5d.png)

Also little note: they start appearing after ~5-10 sec after main plugin loaded. So in first there is no hints, or errors on hover.
You are right. I didn't wait long enough before checking.
Then it looks like a bug to me.

Resolving patch:
diff --git a/plugin/core/windows.py b/plugin/core/windows.py
--- a/plugin/core/windows.py
+++ b/plugin/core/windows.py
@@ -8,6 +8,7 @@
 from .panels import log_server_message
 from .promise import Promise
 from .protocol import Diagnostic
+from .protocol import DiagnosticSeverity
 from .protocol import Error
 from .protocol import Location
 from .sessions import get_plugin
@@ -82,7 +83,8 @@ def diagnostics_intersecting_region_async(
     @abstractmethod
     def diagnostics_touching_point_async(
         self,
-        pt: int
+        pt: int,
+        max_diagnostic_severity_level: int = DiagnosticSeverity.Hint
     ) -> Tuple[Sequence[Tuple[SessionBufferProtocol, Sequence[Diagnostic]]], sublime.Region]:
         raise NotImplementedError()
 
diff --git a/plugin/documents.py b/plugin/documents.py
--- a/plugin/documents.py
+++ b/plugin/documents.py
@@ -6,6 +6,7 @@
 from .core.protocol import CompletionItem
 from .core.protocol import CompletionList
 from .core.protocol import Diagnostic
+from .core.protocol import DiagnosticSeverity
 from .core.protocol import DocumentHighlightKind
 from .core.protocol import Error
 from .core.protocol import Range
@@ -23,6 +24,7 @@
 from .core.typing import Any, Callable, Optional, Dict, Generator, Iterable, List, Tuple, Union
 from .core.url import view_to_uri
 from .core.views import DIAGNOSTIC_SEVERITY
+from .core.views import diagnostic_severity
 from .core.views import document_color_params
 from .core.views import first_selection_region
 from .core.views import format_completion
@@ -276,13 +278,17 @@ def diagnostics_intersecting_region_async(
 
     def diagnostics_touching_point_async(
         self,
-        pt: int
+        pt: int,
+        max_diagnostic_severity_level: int = DiagnosticSeverity.Hint
     ) -> Tuple[List[Tuple[SessionBuffer, List[Diagnostic]]], sublime.Region]:
         covering = sublime.Region(pt, pt)
         result = []  # type: List[Tuple[SessionBuffer, List[Diagnostic]]]
         for sb, diagnostics in self.diagnostics_async():
             intersections = []  # type: List[Diagnostic]
             for diagnostic, candidate in diagnostics:
+                severity = diagnostic_severity(diagnostic)
+                if severity > max_diagnostic_severity_level:
+                    continue
                 if candidate.contains(pt):
                     covering = covering.cover(candidate)
                     intersections.append(diagnostic)
@@ -300,7 +306,8 @@ def _update_diagnostic_in_status_bar_async(self) -> None:
         if userprefs().show_diagnostics_in_view_status:
             r = self._stored_region
             if r is not None:
-                session_buffer_diagnostics, _ = self.diagnostics_touching_point_async(r.b)
+                session_buffer_diagnostics, _ = self.diagnostics_touching_point_async(
+                    r.b, userprefs().show_diagnostics_severity_level)
                 if session_buffer_diagnostics:
                     for _, diagnostics in session_buffer_diagnostics:
                         diag = next(iter(diagnostics), None)
diff --git a/plugin/hover.py b/plugin/hover.py
--- a/plugin/hover.py
+++ b/plugin/hover.py
@@ -102,7 +102,8 @@ def run_async() -> None:
                 return
             if not only_diagnostics:
                 self.request_symbol_hover_async(listener, hover_point)
-            self._diagnostics_by_config, covering = listener.diagnostics_touching_point_async(hover_point)
+            self._diagnostics_by_config, covering = listener.diagnostics_touching_point_async(
+                hover_point, userprefs().show_diagnostics_severity_level)
             if self._diagnostics_by_config:
                 self.show_hover(listener, hover_point, only_diagnostics)
             if not only_diagnostics and userprefs().show_code_actions_in_hover:


Test patch: