Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adjustable extents of the popups #1689

Merged
merged 3 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions LSP.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
// Show symbol references in Sublime's quick panel instead of the bottom panel.
"show_references_in_quick_panel": false,

// The maximum number of characters (approximately) before wrapping in the popup.
"popup_max_characters_width": 120,

// The maximum number of characters (approximately) before a scrollbar appears.
"popup_max_characters_height": 1000,

// Show verbose debug messages in the sublime console.
"log_debug": false,

Expand Down
9 changes: 6 additions & 3 deletions plugin/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def read_list_setting(settings_obj: sublime.Settings, key: str, default: list) -
class Settings:

# This is only for mypy
show_diagnostics_panel_on_save = None # type: int
code_action_on_save_timeout_ms = None # type: int
diagnostics_additional_delay_auto_complete_ms = None # type: int
diagnostics_delay_ms = None # type: int
Expand All @@ -164,9 +163,12 @@ class Settings:
lsp_code_actions_on_save = None # type: Dict[str, bool]
lsp_format_on_save = None # type: bool
only_show_lsp_completions = None # type: bool
popup_max_characters_height = None # type: int
popup_max_characters_width = None # type: int
show_code_actions = None # type: bool
show_diagnostics_count_in_view_status = None # type: bool
show_diagnostics_in_view_status = None # type: bool
show_diagnostics_panel_on_save = None # type: int
show_diagnostics_severity_level = None # type: int
show_references_in_quick_panel = None # type: bool
show_symbol_action_links = None # type: bool
Expand All @@ -181,7 +183,6 @@ def r(name: str, default: Union[bool, int, str, list, dict]) -> None:
val = s.get(name)
setattr(self, name, val if isinstance(val, default.__class__) else default)

r("show_diagnostics_panel_on_save", 2)
r("code_action_on_save_timeout_ms", 2000)
r("diagnostics_additional_delay_auto_complete_ms", 0)
r("diagnostics_delay_ms", 0)
Expand All @@ -192,13 +193,15 @@ def r(name: str, default: Union[bool, int, str, list, dict]) -> None:
r("document_highlight_style", "stippled")
r("log_debug", False)
r("log_max_size", 8 * 1024)
# r("log_server", [])
r("lsp_code_actions_on_save", {})
r("lsp_format_on_save", False)
r("only_show_lsp_completions", False)
r("popup_max_characters_height", 1000)
r("popup_max_characters_width", 120)
r("show_code_actions", "annotation")
r("show_diagnostics_count_in_view_status", False)
r("show_diagnostics_in_view_status", True)
r("show_diagnostics_panel_on_save", 2)
r("show_diagnostics_severity_level", 2)
r("show_references_in_quick_panel", False)
r("show_symbol_action_links", False)
Expand Down
5 changes: 3 additions & 2 deletions plugin/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .protocol import Point
from .protocol import Range
from .protocol import Request
from .settings import userprefs
from .typing import Callable, Optional, Dict, Any, Iterable, List, Union, Tuple, Sequence, cast
from .url import filename_to_uri
from .url import uri_to_filename
Expand Down Expand Up @@ -379,8 +380,8 @@ def show_lsp_popup(view: sublime.View, contents: str, location: int = -1, md: bo
flags=flags,
location=location,
wrapper_class=wrapper_class,
max_width=int(view.em_width() * 120.0), # Around 120 characters per line
max_height=1000000,
max_width=int(view.em_width() * float(userprefs().popup_max_characters_width)),
max_height=int(view.line_height() * float(userprefs().popup_max_characters_height)),
on_navigate=on_navigate)


Expand Down
12 changes: 12 additions & 0 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@
"default": false,
"markdownDescription": "Show symbol references in Sublime's quick panel instead of the bottom panel."
},
"popup_max_characters_width": {
"type": "integer",
"default": 120,
"minimum": 1,
"description": "The maximum number of characters (approximately) before wrapping in the popup."
},
"popup_max_characters_height": {
"type": "integer",
"default": 1000,
"minimum": 1,
"description": "The maximum number of characters (approximately) before a scrollbar appears."
},
"disabled_capabilities": {
"type": "array",
"uniqueItems": true,
Expand Down