Closed ikirkpat closed 1 year ago
When you open any .cs file, whether or not a server is running already, omnisharp-vim searches up the directory tree for a .sln, and if none are found, it searches for a .csproj. This way a single vim session can have many omnisharp servers running simultaneously.
One option for you might be to set let g:OmniSharp_start_server = 0
in your .vimrc, and then manually start the server with OmniSharpStartServer path/to/.sln
(with tab-completion for the .sln filename).
The more correct way to resolve this, which has been discussed before but never implemented properly, is a setting to allow a custom function to be used to find the .sln file. This way users with unusual solution structures like yours can have some logic that says "if I'm under path Root/OtherProjects use Root/backend/MyApp.sln, otherwise continue as per usual". But I don't have time to add this kind of option right now. PRs welcome.
That's actually exactly what I was looking for. I didn't realize OmniSharpStartServer took an explicit argument. Though it just auto found the solution. Thanks!
I have a project where the structure is like so:
The solution file includes both Project1 and Project2. Project1 references Project2. When I open a class in Project2, it seems to be using Project2.csproj as the current project instead of the solution file. This means that I can't do things like FindUsage reliably cause it only looks in Project2.
I think it's getting tripped up cause the solution file isn't in a direct parent directory of Project2.
I've tried to look online to see how to select the solution file manually as the project but it just always uses the project file. In VSCode, there's a command to select the project (see attached screenshot). I need something like that. I've looked at https://github.com/OmniSharp/omnisharp-vim/issues/545 but I can't seem to get it to prompt me to choose the project.
How can I get OmniSharp to use my solution file even if it's in a different path on my computer?