Skip to content

Commit

Permalink
feat: add option to disable/enable diagnostics in hover (#2489)
Browse files Browse the repository at this point in the history
* feat: add option to disable/enable diagnostics in hover

* fix: fix lsp next/prev diagnostics command

was not working after addition of setting 'show diagnostics in hover'

* Update plugin/hover.py

---------

Co-authored-by: Rafał Chłodnicki <[email protected]>
  • Loading branch information
HJX-001 and rchl authored Jun 4, 2024
1 parent cd7cb68 commit 7554363
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions LSP.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
// The maximum number of characters (approximately) before a scrollbar appears.
"popup_max_characters_height": 1000,

// Show diagnostics in hover popup if available
"show_diagnostics_in_hover": true,

// Show code actions in hover popup if available
"show_code_actions_in_hover": true,

Expand Down
2 changes: 2 additions & 0 deletions plugin/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class Settings:
show_code_actions = cast(str, None)
show_code_lens = cast(str, None)
show_inlay_hints = cast(bool, None)
show_diagnostics_in_hover = cast(bool, None)
show_code_actions_in_hover = cast(bool, None)
show_diagnostics_annotations_severity_level = cast(int, None)
show_diagnostics_count_in_view_status = cast(bool, None)
Expand Down Expand Up @@ -271,6 +272,7 @@ def r(name: str, default: bool | int | str | list | dict) -> None:
r("show_code_actions", "annotation")
r("show_code_lens", "annotation")
r("show_inlay_hints", False)
r("show_diagnostics_in_hover", True)
r("show_code_actions_in_hover", True)
r("show_diagnostics_annotations_severity_level", 0)
r("show_diagnostics_count_in_view_status", False)
Expand Down
5 changes: 3 additions & 2 deletions plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ def show_hover(self, listener: AbstractViewListener, point: int, only_diagnostic

def _show_hover(self, listener: AbstractViewListener, point: int, only_diagnostics: bool) -> None:
hover_content = self.hover_content()
contents = self.diagnostics_content() + hover_content + code_actions_content(self._actions_by_config)
prefs = userprefs()
diagnostics_content = self.diagnostics_content() if only_diagnostics or prefs.show_diagnostics_in_hover else ""
contents = diagnostics_content + hover_content + code_actions_content(self._actions_by_config)
link_content, link_range = self.link_content_and_range()
only_link_content = not bool(contents) and link_range is not None
prefs = userprefs()
if prefs.show_symbol_action_links and contents and not only_diagnostics and hover_content:
symbol_actions_content = self.symbol_actions_content(listener, point)
if link_content:
Expand Down
5 changes: 5 additions & 0 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@
"default": "annotation",
"markdownDescription": "Where to show `\"code lens\"`."
},
"show_diagnostics_in_hover": {
"type": "boolean",
"default": true,
"markdownDescription": "Show diagnostics in hover popup if available."
},
"show_code_actions_in_hover": {
"type": "boolean",
"default": true,
Expand Down

0 comments on commit 7554363

Please sign in to comment.