Skip to content

Add Lint Trigger #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion pyls/hookspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def pyls_initialize(config, workspace):


@hookspec
def pyls_lint(config, workspace, document):
def pyls_lint(config, workspace, document, trigger):
pass


Expand Down
14 changes: 7 additions & 7 deletions pyls/python_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down