-
Notifications
You must be signed in to change notification settings - Fork 420
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
InlayHints not working on neovim #2550
Comments
I have the same problem with neovim on Windows |
I second this, neovim is not triggering any inlay hints regardless |
To support inlay hints we will need a release of https://github.com/OmniSharp/csharp-language-server-protocol with updates from the 3.17 spec. |
The configuration in lsp-config does not pass in the necessary arguments for inlayHints, but even with my patch (where I added the necessary configuration), I get responses that it is not implemented. |
EDIT: Never mind! I built the newest version of Neovim ( Original text: omnisharp: -32603: Internal Error - System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')
at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)
at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in /home/vsts/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 28
at OmniSharp.Extensions.TextExtensions.GetSpanFromRange(SourceText text, Range range) in /home/vsts/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 55
at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.Handle(InlayHintRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/InlayHints/InlayHintService.cs:line 60
at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpInlayHintHandler.Handle(InlayHintParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handle
rs/OmniSharpInlayHintHandler.cs:line 56
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token,
ILogger logger)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() This is my {
"RoslynExtensionsOptions": {
"inlayHintsOptions": {
"enableForParameters": true,
"forLiteralParameters": true,
"forIndexerParameters": true,
"forObjectCreationParameters": true,
"forOtherParameters": true,
"suppressForParametersThatDifferOnlyBySuffix": false,
"suppressForParametersThatMatchMethodIntent": false,
"suppressForParametersThatMatchArgumentName": false,
"enableForTypes": true,
"forImplicitVariableTypes": true,
"forLambdaParameterTypes": true,
"forImplicitObjectCreation": true
}
}
} Here is an excerpt from the LSP interaction logs: [ERROR][2023-10-05 10:10:03] ...lsp/handlers.lua:543 "OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/inlayHint 11 - System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')\n at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\n at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in /home/vsts/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 28\n at OmniSharp.Extensions.TextExtensions.GetSpanFromRange(SourceText text, Range range) in /home/vsts/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 55\n at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.Handle(InlayHintRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/InlayHints/InlayHintService.cs:line 60\n at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpInlayHintHandler.Handle(InlayHintParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpInlayHintHandler.cs:line 56\n at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)\n at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)\n at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)\n at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext() | Method='textDocument/inlayHint' RequestId='11'" I lack the knowledge to debug this issue effectively, unfortunately. Any ideas as to what might be wrong? Is the problem my configuration, or is the problem on |
I will verify this fix later today. Thanks @JoeRobich |
@bmvi-kinver would you be able to share more about your setup if you have this working? I snooped on your profile but didn't find any dotfiles there :) I'm running neovim nightly (
|
@tanordheim I can certainly share my config, but it seems that I was too quick to pull the trigger as I'm now experiencing the same problem as you are -- but only for particular files, while for other files it appears to be working properly. In my own project, it looks like inlay hints don't work for any files that has |
Inlay hints work fine for me about half of the time (otherwise spitting out the above object reference not set error), although both textDocument_inlayHint AND textDocument_hover are incorrectly reported. As long as I hardcode them as enabled for omnisharp instead of checking client.supportsMethod, it works. This is on neovim master. |
I get that same object reference error in both Helix, and VSCode (c# extension installed, OmniSharp enabled, and LSP drivers enabled) |
In the end I decided to try to build the repo locally and try to find the bug, the problem will happen always when there is a lambda as a parameter of a function (so very common if you use LINQ as an example) I've successfully made a change to fix the problem! I opened a PR, hopefully it gets merged if I did not miss any detail while debugging the code, in the meanwhile you can build my branch with (note that I'm using neovim on windows x64, edit the path based on where you build) cmd = {
"C:\\path\\to\\repo\\omnisharp-roslyn\\artifacts\\publish\\OmniSharp.Stdio.Driver\\win7-x64\\net6.0\\OmniSharp.exe",
"-z",
"--hostPID",
tostring(vim.fn.getpid()),
"DotNet:enablePackageRestore=false",
"--encoding",
"utf-8",
"--languageserver",
"FormattingOptions:EnableEditorConfigSupport=true",
"FormattingOptions:OrganizeImports=true",
"RoslynExtensionsOptions:EnableAnalyzersSupport=true",
"RoslynExtensionsOptions:EnableImportCompletion=true",
"Sdk:IncludePrereleases=true",
}, |
fix #2550 inlay hints lambdas parameter type null reference exception
just update your nvim to 0.10 and add omnisharp.json file in your project directory with this and then in nvim run :lua vim.lsp.inlay_hint.enable(true) you can set keymap to toggle inlay hint with |
Description
The source code indicates that omnisharp-roslyn already supports
InlayHint
, but testing fromneovim
reports that omnisharp does not supporttextDocument/inlayHint
How to reproduce
Start omnisharp using the following command
I use a fork of
nvim-lspconfig
that adds the necessary command-line parameters to enableinlayHint
LSP Log (original)
LSP Log (pretending that the server supports inlayHint, so that client can at least send the request)
System Details
The text was updated successfully, but these errors were encountered: