diff --git a/pyls/hookspecs.py b/pyls/hookspecs.py index d094dcb5..44e4ee15 100644 --- a/pyls/hookspecs.py +++ b/pyls/hookspecs.py @@ -88,7 +88,7 @@ def pyls_initialize(config, workspace): @hookspec -def pyls_lint(config, workspace, document): +def pyls_lint(config, workspace, document, trigger): pass diff --git a/pyls/python_ls.py b/pyls/python_ls.py index eda0e02f..80b1853e 100644 --- a/pyls/python_ls.py +++ b/pyls/python_ls.py @@ -194,10 +194,10 @@ def hover(self, doc_uri, position): return self._hook('pyls_hover', doc_uri, position=position) or {'contents': ''} @_utils.debounce(LINT_DEBOUNCE_S, keyed_by='doc_uri') - def lint(self, doc_uri): + def lint(self, doc_uri, trigger): # Since we're debounced, the document may no longer be open if doc_uri in self.workspace.documents: - self.workspace.publish_diagnostics(doc_uri, flatten(self._hook('pyls_lint', doc_uri))) + self.workspace.publish_diagnostics(doc_uri, flatten(self._hook('pyls_lint', doc_uri, trigger=trigger))) def references(self, doc_uri, position, exclude_declaration): return flatten(self._hook( @@ -217,7 +217,7 @@ def m_text_document__did_close(self, textDocument=None, **_kwargs): def m_text_document__did_open(self, textDocument=None, **_kwargs): self.workspace.put_document(textDocument['uri'], textDocument['text'], version=textDocument.get('version')) self._hook('pyls_document_did_open', textDocument['uri']) - self.lint(textDocument['uri']) + self.lint(textDocument['uri'], trigger='open') def m_text_document__did_change(self, contentChanges=None, textDocument=None, **_kwargs): for change in contentChanges: @@ -226,10 +226,10 @@ def m_text_document__did_change(self, contentChanges=None, textDocument=None, ** change, version=textDocument.get('version') ) - self.lint(textDocument['uri']) + self.lint(textDocument['uri'], trigger='change') def m_text_document__did_save(self, textDocument=None, **_kwargs): - self.lint(textDocument['uri']) + self.lint(textDocument['uri'], trigger='save') def m_text_document__code_action(self, textDocument=None, range=None, context=None, **_kwargs): return self.code_actions(textDocument['uri'], range, context) @@ -273,12 +273,12 @@ def m_text_document__signature_help(self, textDocument=None, position=None, **_k def m_workspace__did_change_configuration(self, settings=None): self.config.update((settings or {}).get('pyls', {})) for doc_uri in self.workspace.documents: - self.lint(doc_uri) + self.lint(doc_uri, trigger='change-configuration') def m_workspace__did_change_watched_files(self, **_kwargs): # Externally changed files may result in changed diagnostics for doc_uri in self.workspace.documents: - self.lint(doc_uri) + self.lint(doc_uri, trigger='change-watched-files') def m_workspace__execute_command(self, command=None, arguments=None): return self.execute_command(command, arguments)