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

feat(API): allow setting additional text in permanent server status #2173

Merged
merged 2 commits into from
Jan 22, 2023
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
11 changes: 11 additions & 0 deletions plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ def __init__(self, manager: Manager, logger: Logger, workspace_folders: List[Wor
self._logger = logger
self._response_handlers = {} # type: Dict[int, Tuple[Request, Callable, Optional[Callable[[Any], None]]]]
self.config = config
self.config_status_message = ''
self.manager = weakref.ref(manager)
self.window = manager.window
self.state = ClientStates.STARTING
Expand Down Expand Up @@ -1205,6 +1206,16 @@ def session_view_for_view_async(self, view: sublime.View) -> Optional[SessionVie
return sv
return None

def set_config_status_async(self, message: str) -> None:
"""
Sets the message that is shown in parenthesis within the permanent language server status.

:param message: The message
"""
self.config_status_message = message.strip()
for sv in self.session_views_async():
self.config.set_view_status(sv.view, message)

def set_window_status_async(self, key: str, message: str) -> None:
self._status_messages[key] = message
for sv in self.session_views_async():
Expand Down
2 changes: 1 addition & 1 deletion plugin/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def resolve_transport_config(self, variables: Dict[str, str]) -> TransportConfig

def set_view_status(self, view: sublime.View, message: str) -> None:
if sublime.load_settings("LSP.sublime-settings").get("show_view_status"):
status = "{}: {}".format(self.name, message) if message else self.name
status = "{} ({})".format(self.name, message) if message else self.name
view.set_status(self.status_key, status)

def erase_view_status(self, view: sublime.View) -> None:
Expand Down
2 changes: 1 addition & 1 deletion plugin/session_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, listener: AbstractViewListener, session: Session, uri: Docume
session_buffer.add_session_view(self)
self._session_buffer = session_buffer
session.register_session_view_async(self)
session.config.set_view_status(self._view, "")
session.config.set_view_status(self._view, session.config_status_message)
if self._session.has_capability(self.HOVER_PROVIDER_KEY):
self._increment_hover_count()
self._clear_auto_complete_triggers(settings)
Expand Down