OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 420 forks source link

Not showing any completion for UnityEngine #1737

Open Falconerd opened 4 years ago

Falconerd commented 4 years ago

Hello, I have tried a few things such as removing dotnet completely, having both dotnet and mono, installing msbuild from the AUR, installing the Unity Game Engine for Arch.

I am running the Unity Game Engine on Windows and trying to use Neovim through Arch on WSL2 as my text editor.

Auto-complete works for native C# such as List..., IEnumerator, etc. However nothing is coming up for the unity classes.

I'm unsure what else to do, any help is appreciated.

OS: Arch (via WSL2)
Editor: Neovim
Plugin: omnisharp-vim

OmniSharp log

3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Starting OmniSharp on arch 0.0 (x64)"},"Seq":1,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Services.DotNetCliService","Message":"DotNetPath set to dotnet"},"Seq":2,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.Discovery.MSBuildLocator","Message":"Located 2 MSBuild instance(s)\n            1: Mono 16.4 - \"/usr/lib/mono/msbuild/Current/bin\"\n            2: StandAlone 16.4 - \"/home/falconerd/.cache/omnisharp-vim/omnisharp-roslyn/.msbuild/Current/Bin\""},"Seq":3,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.Discovery.MSBuildLocator","Message":"Registered MSBuild instance: Mono 16.4 - \"/usr/lib/mono/msbuild/Current/bin\"\n            CscToolExe = csc.exe\n            CscToolPath = /home/falconerd/.cache/omnisharp-vim/omnisharp-roslyn/.msbuild/Current/Bin/Roslyn"},"Seq":4,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Cake.CakeProjectSystem","Message":"Detecting Cake files in '/mnt/c/Users/Dylan Falconer/dev/omnisharp-test'."},"Seq":5,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Cake.CakeProjectSystem","Message":"Could not find any Cake files"},"Seq":6,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectSystem","Message":"No solution files found in '/mnt/c/Users/Dylan Falconer/dev/omnisharp-test'"},"Seq":7,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Script.ScriptProjectSystem","Message":"Detecting CSX files in '/mnt/c/Users/Dylan Falconer/dev/omnisharp-test'."},"Seq":8,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Script.ScriptProjectSystem","Message":"Could not find any CSX files"},"Seq":9,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0"},"Seq":10,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100"},"Seq":11,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110"},"Seq":12,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200"},"Seq":13,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.WorkspaceInitializer","Message":"Configuration finished."},"Seq":14,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Stdio.Host","Message":"Omnisharp server running using Stdio at location '/mnt/c/Users/Dylan Falconer/dev/omnisharp-test' on host -1."},"Seq":15,"Type":"event"}
3  {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.OmniSharpWorkspace","Message":"Miscellaneous file: /mnt/c/Users/Dylan Falconer/dev/omnisharp-test/Assets/ACSScript.cs added to workspace"},"Seq":18,"Type":"event"}
SirIntruder commented 4 years ago

3 {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectSystem","Message":"No solution files found in '/mnt/c/Users/Dylan Falconer/dev/omnisharp-test'"},"Seq":7,"Type":"event"}

Omnisharp didn't find solution .sln file at all, and is targetting folder as a group of random .cs files. Most likely Unity didn't generate .sln and .csproj files at all. You will probably need to tweak with Unity preferences for external test editor.

ijacquez commented 4 years ago

On Linux, I generate my .sln files via a script, update-solution.sh. It calls Unity directly:

TERM="xterm" "${UNITY_PATH}" -projectPath "${PROJECT_PATH}" -batchmode -quit -nographics -logFile - -executeMethod "UnityEditor.SyncVS.SyncSolution"

You can guess what the environment variables are...

There is one slight problem in that even after I call the above, Omnisharp doesn't update. For example, if I add a file, it won't pick it up until I kill and restart the process.

SirIntruder commented 4 years ago

Normally, Unity regenerates csproj when you add a new file, and omnisharp picks up on that. Omnisharp never changes .csproj files.

ijacquez commented 4 years ago

Normally, Unity regenerates csproj when you add a new file, and omnisharp picks up on that. Omnisharp never changes .csproj files.

Yes, that's exactly right. However, Omnisharp doesn't pick up on it, not until I restart it. I'll verify what's happening.

SirIntruder commented 4 years ago

Potential failure point crossed my mind, o# relies on outside FileWatcherService (like the one in vscode), hooking into file system and sending "FileChanged" messages to omnisharp whenever any file in the directory gets changed. I don't think Omnisharp will respond on its own.

filipw commented 4 years ago

I don't think Omnisharp will respond on its own.

correct, the "change" event must be submitted by the editor

ijacquez commented 4 years ago

correct, the "change" event must be submitted by the editor

Thanks for the info. I'm (quickly) looking into Omnisharp for Emacs, and I don't see any "change" related event. I only see something like "updatebuffer".

nickspoons commented 4 years ago

We don't use a "change" event in OmniSharp-vim either, just /updateBuffer. There is no endpoint called /change, but there are /filesChanged and /changeBuffer, as well as /open and /close. In my experience in both .NET Core and .NET Framework, none of these are necessary. Although I'll admit to restarting the server after too many changes sometimes. I'd love a quick overview over what these endpoints do?