Description
I am having myriad issues getting the LSP to work like at all, particularly for a newly-bootstrapped Unity project.
To start, my current setup (abbreviated, omitting some details that I suspect aren't relevant):
- .NET SDK 9.0 via https://dotnet.microsoft.com/en-us/download
- Using
omnisharp-osx-arm64-net6.0.tar.gz
from the latest release as of writing this (1.39.13) - I have tried multiple editors (I am not interested in using VS Code or such):
- emacs
- helix
Of note is that I tried using the various mono-based builds/interactions (the omnisharp-mono
brew package and the omnisharp-osx
release tarballs) and those all failed in a variety of ways, all of which mostly boiling down to being unable to find MSBuild or the standard library for whatever reason. Didn't seem like there was a particularly obvious way either to "just" point omnisharp at whatever .NET I have installed. Namely, would most consistently get the error: Could not locate MSBuild instance to register with OmniSharp
. I even tried creating a project-local omnisharp.json
with the following to see if that would work, but still nothing:
{"msbuild":{"MSBuildSDKsPath":"/usr/local/share/dotnet/sdk/9.0.200"}}
I have been trying to pour over the source and documentation, yet I see nothing obvious which allows me to just point omnisharp at my installation. Also of course I don't understand why I should even need to with a seemingly standard installation of .NET and its CLIs (e.g. dotnet
) confirmed in my path.
So then I switched to using omnisharp-osx-arm64-net6.0.tar.gz
and executing the binary via dotnet OmniSharp.dll --languageserver
; however, that then fails because Unity generates the project with multiple .csproj
files I guess as I get the following error when trying to start the LSP:
"Specify which project file to use because this '<path_to_my_project_directory>' contains more than one project file"
I thought then that perhaps I should point omnisharp at the .sln
file, but that then failed with:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at OmniSharp.Services.OmniSharpEnvironment..ctor(String path, Int32 hostPid, LogLevel logLevel, String[] additionalArguments) in /Users/runner/work/1/s/src/OmniSharp.Host/Services/OmniSharpEnvironment.cs:line 16
at OmniSharp.CommandLineApplicationExtensions.CreateEnvironment(CommandLineApplication application) in /Users/runner/work/1/s/src/OmniSharp.Host/CommandLineApplicationExtensions.cs:line 12
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in /Users/runner/work/1/s/src/OmniSharp.Stdio.Driver/Program.cs:line 49
at OmniSharp.CommandLineApplication.<>c__DisplayClass12_0.<OnExecute>b__0() in /Users/runner/work/1/s/src/OmniSharp.Host/CommandLineApplication.cs:line 92
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at OmniSharp.CommandLineApplication.Execute(String[] args) in /Users/runner/work/1/s/src/OmniSharp.Host/CommandLineApplication.cs:line 65
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_0.<Main>b__0() in /Users/runner/work/1/s/src/OmniSharp.Stdio.Driver/Program.cs:line 84
at OmniSharp.HostHelpers.Start(Func`1 action) in /Users/runner/work/1/s/src/OmniSharp.Host/HostHelpers.cs:line 30
Which is particularly strange because if I run omnisharp without supplying --languageserver
, it starts up just fine and doesn't run into this error. Which makes me suspect that there is potentially a bug in how .sln
files are parsed/used.
All else then that I can find in the way of support or documentation or previous user experiences is tied to using VS Code or the editor extensions within this org. Given that, it seems like omnisharp is not actually meant to be invoked standalone as I am trying and is only supported through those extensions? I'm not particularly a big fan of that; however, I can understand if that's just how things are. I would ask though that is made more explicit in documentation then please.