From eba4c0ead802c172b33770c87debf801b19ee9c3 Mon Sep 17 00:00:00 2001 From: Dylan Mayor <36193755+Dylmay@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:18:35 +0100 Subject: [PATCH 1/2] Add log message --- pylsp/workspace.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pylsp/workspace.py b/pylsp/workspace.py index f047ed08..59d73aef 100644 --- a/pylsp/workspace.py +++ b/pylsp/workspace.py @@ -41,6 +41,7 @@ class Workspace: M_INITIALIZE_PROGRESS = "window/workDoneProgress/create" M_APPLY_EDIT = "workspace/applyEdit" M_SHOW_MESSAGE = "window/showMessage" + M_LOG_MESSAGE = "window/logMessage" def __init__(self, root_uri, endpoint, config=None): self._config = config @@ -323,6 +324,11 @@ def _progress_end(self, token: str, message: Optional[str] = None) -> None: "value": value, }, ) + + def log_message(self, message, msg_type=lsp.MessageType.Info): + self._endpoint.notify( + self.M_LOG_MESSAGE, params={"type": msg_type, "message": message} + ) def show_message(self, message, msg_type=lsp.MessageType.Info): self._endpoint.notify( From 4ba32503ae2698006fbb465e17e8e73f0e3a80fe Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Wed, 24 Jul 2024 11:46:18 -0500 Subject: [PATCH 2/2] Linting fixes --- pylsp/python_lsp.py | 8 ++++++-- pylsp/workspace.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pylsp/python_lsp.py b/pylsp/python_lsp.py index 8606aba1..d50d5242 100644 --- a/pylsp/python_lsp.py +++ b/pylsp/python_lsp.py @@ -442,13 +442,17 @@ def lint(self, doc_uri, is_saved): workspace = self._match_uri_to_workspace(doc_uri) document_object = workspace.documents.get(doc_uri, None) if isinstance(document_object, Document): - self._lint_text_document(doc_uri, workspace, is_saved, document_object.version) + self._lint_text_document( + doc_uri, workspace, is_saved, document_object.version + ) elif isinstance(document_object, Notebook): self._lint_notebook_document(document_object, workspace) def _lint_text_document(self, doc_uri, workspace, is_saved, doc_version=None): workspace.publish_diagnostics( - doc_uri, flatten(self._hook("pylsp_lint", doc_uri, is_saved=is_saved)), doc_version, + doc_uri, + flatten(self._hook("pylsp_lint", doc_uri, is_saved=is_saved)), + doc_version, ) def _lint_notebook_document(self, notebook_document, workspace): diff --git a/pylsp/workspace.py b/pylsp/workspace.py index 59d73aef..c9b63a99 100644 --- a/pylsp/workspace.py +++ b/pylsp/workspace.py @@ -324,7 +324,7 @@ def _progress_end(self, token: str, message: Optional[str] = None) -> None: "value": value, }, ) - + def log_message(self, message, msg_type=lsp.MessageType.Info): self._endpoint.notify( self.M_LOG_MESSAGE, params={"type": msg_type, "message": message}