Description
I been trying to get textDocument/codeAction
working with VS Code but it's impossible to get any call to that endpoint from vscode with a omnisharp LSP server using handlers. My handler is implementing ICodeActionHandler
.
I dig a bit the issue and it seems to came from server capabilities that are not set correctly on the Initialize
request.
LanguageServer.Handle
method for the Initialize request is setting server capabilities based on received client capabilities
The GetStaticOptions
will set the capability to false if the client capability support DynamicRegistration
.
That will end up to send capabilities with a
codeActionProvider
to false to the client, which seems to be the source of the problem. Even if it supposed to dynamic registered VS Code seems to have to receive the codeActionProvider
capability to true on initilialization in order to have the codeAction working. I verified my hypothesis by "hacking" the client request on the OnInitialize
of my server to skip the dynamic registration thing:
var serverOptions = new LanguageServerOptions()
.WithInput(stream)
.WithOutput(stream)
.WithServices(ConfigureServices)
.WithHandler<TextDocumentHandler>()
.OnInitialize((server, request, token) =>
{
request.Capabilities.TextDocument.CodeAction.Value.DynamicRegistration = false;
return Task.CompletedTask;
});
and it's indeed working, and now I receive textDocument/codeAction
events from vs code. This also seems to be documented on the vscode side: https://code.visualstudio.com/api/language-extensions/programmatic-language-features#possible-actions-on-errors-or-warnings (under Possible Actions on Errors or Warnings/Language Server Protocol)
Am I missing something about Omnisharp LSP server regarding the management of capabilities or is there an issue here? I always make it worked with just implemented the right interface on my handlers, and thought it was the way to go.
I'm using version 0.17.4, but I also had the issue on 0.15.0.