Skip to content
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
8 changes: 6 additions & 2 deletions pylsp/python_lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions pylsp/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -324,6 +325,11 @@ def _progress_end(self, token: str, message: Optional[str] = None) -> None:
},
)

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(
self.M_SHOW_MESSAGE, params={"type": msg_type, "message": message}
Expand Down