Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit e8dd582

Browse files
authored
Add window/logMessage support (python-lsp#573)
1 parent 9b79576 commit e8dd582

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pylsp/python_lsp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,17 @@ def lint(self, doc_uri, is_saved):
442442
workspace = self._match_uri_to_workspace(doc_uri)
443443
document_object = workspace.documents.get(doc_uri, None)
444444
if isinstance(document_object, Document):
445-
self._lint_text_document(doc_uri, workspace, is_saved, document_object.version)
445+
self._lint_text_document(
446+
doc_uri, workspace, is_saved, document_object.version
447+
)
446448
elif isinstance(document_object, Notebook):
447449
self._lint_notebook_document(document_object, workspace)
448450

449451
def _lint_text_document(self, doc_uri, workspace, is_saved, doc_version=None):
450452
workspace.publish_diagnostics(
451-
doc_uri, flatten(self._hook("pylsp_lint", doc_uri, is_saved=is_saved)), doc_version,
453+
doc_uri,
454+
flatten(self._hook("pylsp_lint", doc_uri, is_saved=is_saved)),
455+
doc_version,
452456
)
453457

454458
def _lint_notebook_document(self, notebook_document, workspace):

pylsp/workspace.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Workspace:
4141
M_INITIALIZE_PROGRESS = "window/workDoneProgress/create"
4242
M_APPLY_EDIT = "workspace/applyEdit"
4343
M_SHOW_MESSAGE = "window/showMessage"
44+
M_LOG_MESSAGE = "window/logMessage"
4445

4546
def __init__(self, root_uri, endpoint, config=None):
4647
self._config = config
@@ -324,6 +325,11 @@ def _progress_end(self, token: str, message: Optional[str] = None) -> None:
324325
},
325326
)
326327

328+
def log_message(self, message, msg_type=lsp.MessageType.Info):
329+
self._endpoint.notify(
330+
self.M_LOG_MESSAGE, params={"type": msg_type, "message": message}
331+
)
332+
327333
def show_message(self, message, msg_type=lsp.MessageType.Info):
328334
self._endpoint.notify(
329335
self.M_SHOW_MESSAGE, params={"type": msg_type, "message": message}

0 commit comments

Comments
 (0)