Skip to content
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

Support for linting on change. #83

Closed
alkatar21 opened this issue May 6, 2022 · 5 comments · Fixed by #368
Closed

Support for linting on change. #83

alkatar21 opened this issue May 6, 2022 · 5 comments · Fixed by #368
Labels
feature-request Request for new features or functionality needs community feedback verified Verification succeeded
Milestone

Comments

@alkatar21
Copy link

The inline hints that highlight problems in the code do not behave as expected on unsaved files. While pylance/pyright move the hints, the pylint problem hints do not.

I'm not quite sure if it's more of a bug or a feature request?

Since I do not know how best to create a gif here at least 2 images (The red lines are pylance and the blue and yellow one are from pylint.):
grafik
grafik

@github-actions github-actions bot added the triage-needed Issue is not triaged. label May 6, 2022
@karthiknadig karthiknadig changed the title [Bug] Problem hints do not move when new lines are added above Support for linting on change. May 6, 2022
@karthiknadig karthiknadig added feature-request Request for new features or functionality needs community feedback and removed triage-needed Issue is not triaged. labels May 6, 2022
@karthiknadig
Copy link
Member

@alkatar21 Changing this to a feature request. What we need here is to support linting on change.

Currently, we support linting on open, save and clean up on close, we will need to add on change support here:

@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_OPEN)
def did_open(_server: server.LanguageServer, params: types.DidOpenTextDocumentParams):
"""LSP handler for textDocument/didOpen request."""
_lint_and_publish_diagnostics(params)
@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_SAVE)
def did_save(_server: server.LanguageServer, params: types.DidSaveTextDocumentParams):
"""LSP handler for textDocument/didSave request."""
_lint_and_publish_diagnostics(params)
@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_CLOSE)
def did_close(_server: server.LanguageServer, params: types.DidCloseTextDocumentParams):
"""LSP handler for textDocument/didClose request."""
# Publishing empty diagnostics to clear the entries for this file.
text_document = LSP_SERVER.workspace.get_document(params.text_document.uri)
LSP_SERVER.publish_diagnostics(text_document.uri, [])

A caveat with supporting on change is we may also have to support cancel request. Users may also want the ability to turnoff linting on change.

/cc @luabud

@luabud
Copy link
Member

luabud commented May 6, 2022

Related to microsoft/vscode-python#408

@karthiknadig
Copy link
Member

karthiknadig commented Jun 2, 2022

If we do this, it should be put behind pylint.lintOnChange setting scoped to the machine level. Propagate that setting in settings.ts.

Registration in LSP itself can be done in initialize in linter_server.py:

if setting["lintOnChange"]:
    @LSP_SERVER.feature(lsp.TEXT_DOCUMENT_DID_CHANGE) 
    def did_change(_server: server.LanguageServer, params: types.DidSaveTextDocumentParams): 
        """LSP handler for textDocument/didChange request.""" 
        _lint_and_publish_diagnostics(params) 

@karthiknadig
Copy link
Member

Closed via #368

@luabud
Copy link
Member

luabud commented Aug 28, 2023

verified:
image

@luabud luabud added the verified Verification succeeded label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality needs community feedback verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants