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

Built-in code actions to provide fix for diagnostics results #396

Open
renkun-ken opened this issue Mar 21, 2021 · 2 comments
Open

Built-in code actions to provide fix for diagnostics results #396

renkun-ken opened this issue Mar 21, 2021 · 2 comments

Comments

@renkun-ken
Copy link
Member

It might make some sense to provide code actions to fix code for diagnostics results from lintr given the list of linters.

The fix of many linters could be quite easy (e.g. assignment_linter, commas_linter, implicit_integer_linter, T_and_F_symbol_linter) while others not trivial or impossible to fix (e.g. cyclocomp_linter) without user discretion.

The problem here is that should the possible fix of each linter should be implemented in the lintr package itself, or another package, or in languageserver?

I guess lintr package is the ideal place to provide possible fixes, i.e. if a linter finds an issue in the code, then it has the best knowledge of how it should be fixed. If each lint result also provides an optional fix field that contains a list of edits (not necessarily using exactly the same data structure in lsp), each contains a range and new text (just like https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit), then it is much easier for us to transform these edits to WorkspaceEdit provided in code actions.

@jooyoungseo
Copy link

It would be so nice if Quick Fix could be implemented.

@renkun-ken
Copy link
Member Author

With r-lib/lintr#785 and #397, the following screencast is a simple demo:

Kapture 2021-03-21 at 23 35 50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants