Skip to content

Commit

Permalink
feat(API): allow setting additional text in permanent server status (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Jan 22, 2023
1 parent ba5aba3 commit bf5a1f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,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 @@ -1208,6 +1209,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

0 comments on commit bf5a1f2

Please sign in to comment.