Skip to content

add "Quick Fix"/"Code Action" implementation example to Language Server Extension Guide #517

@hamirmahal

Description

@hamirmahal

https://code.visualstudio.com/api/language-extensions/language-server-extension-guide has detailed documentation on simple validation and publishing diagnostics: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide#adding-a-simple-validation.

It would be really helpful if the documentation could also show the "correct" way, if such a thing exists, to communicate between the client and server when there is an appropriate "Quick Fix" or "Code Action" for a diagnostic.

For instance, in the example, we add diagnostics for words that have more than two uppercase letters. Even just documentation describing how to do something simple, like converting those words to lowercase, or deleting those words, would be very instructive.

To be specific, it would be extremely helpful to know what code to write in extension.ts and server.ts to achieve that functionality.

@dbaeumer I'd be more than happy to write, proofread, and contribute documentation for this, if you could describe to me the steps, both at a high-level, and low-level, meaning in terms of the actual code, on how to add basic "Quick Fix" and "Code Action" functionality.

@rictic has a very helpful comment in microsoft/language-server-protocol#144, but it provides a high-level overview, and not the specific code to write in server.ts and extension.ts.

@kdvolder also created a Stack Overflow post regarding this topic: https://stackoverflow.com/questions/43328582/how-to-implement-quickfix-via-a-language-server. It is also useful, but it, too, provides a high-level overview, and not code examples to implement the "Quick Fix" functionality. There's a corresponding issue in microsoft/language-server-protocol#219.

Metadata

Metadata

Labels

help wantedIssues identified as good community contribution opportunities

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions