PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
637 stars 219 forks source link

Failed to load PowerShellEditorServices with lspconfig (nvim) #1663

Closed rudesome closed 2 years ago

rudesome commented 2 years ago

Followed the instructions on: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#powershell_es I only set the bundle_path, installed powershell from: https://aur.archlinux.org/packages/powershell/ and downloaded and unzipped the latest PowerShellEditorServices (3.1.0) in my home directory.

I get the error:

[START][2022-01-13 10:58:50] LSP logging initiated
[ERROR][2022-01-13 10:58:59] ...lsp/handlers.lua:404    "OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/completion 5 - System.ArgumentOutOfRangeException: Value is not between 1 and 0 (Parameter 'lineNumber')\nActual value was 1.\n   at Microsoft.PowerShell.EditorServices.Utility.Validate.IsWithinRange(String parameterName, Int32 valueToCheck, Int32 lowerLimit, Int32 upperLimit) in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Utility\\Validate.cs:line 46\n   at Microsoft.PowerShell.EditorServices.Services.TextDocument.ScriptFile.GetOffsetAtPosition(Int32 lineNumber, Int32 columnNumber) in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Services\\TextDocument\\ScriptFile.cs:line 414\n   at Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler.GetCompletionsInFileAsync(ScriptFile scriptFile, Int32 lineNumber, Int32 columnNumber) in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Services\\TextDocument\\Handlers\\CompletionHandler.cs:line 161\n   at Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Services\\TextDocument\\Handlers\\CompletionHandler.cs:line 72\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/completion' RequestId='5'"
[ERROR][2022-01-13 11:00:14] .../vim/lsp/rpc.lua:420    "rpc"   "pwsh"  "stderr"        "Exception encountered starting EditorServices. Exception logged in D:\\a\\1\\s\\src\\PowerShellEditorServices.Hosting\\Commands\\StartEditorServicesCommand.cs on line 252 in EndProcessing:\nSystem.Threading.ThreadStateException: Thread has not been started.\n   at System.Threading.Thread.Join(Int32 millisecondsTimeout)\n   at System.Threading.Thread.Join()\n   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.TriggerShutdown() in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Services\\PowerShell\\Host\\PsesInternalHost.cs:line 247\n   at Microsoft.PowerShell.EditorServices.Server.PsesLanguageServer.WaitForShutdown() in D:\\a\\1\\s\\src\\PowerShellEditorServices\\Server\\PsesLanguageServer.cs:line 164\n   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.CreateEditorServicesAndRunUntilShutdown() in D:\\a\\1\\s\\src\\PowerShellEditorServices.Hosting\\Internal\\EditorServicesRunner.cs:line 188\n   at Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing() in D:\\a\\1\\s\\src\\PowerShellEditorServices.Hosting\\Commands\\StartEditorServicesCommand.cs:line 247\n"

in lspinfo it show as active/attached: lsp_powershell_es

full command is: pwsh -NoLogo -NoProfile -Command ~/PowerShellEditorServices/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath ~/PowerShellEditorServices -LogPath ~/.cache/nvim/powershell_es.log -SessionDetailsPath ~/.cache/nvim/powershell_es.session.json -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Normal

any ideas what this is and how to solve it?

andyleejordan commented 2 years ago

Well that's an off-by-one error to be sure, but I don't know why nothing else has hit it yet.

andyleejordan commented 2 years ago

FYI @rudesome I've added an end-to-end regression test for Vim with PSES: https://github.com/PowerShell/PowerShellEditorServices/pull/1874

ghost commented 2 years ago

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.