Closed starteleport closed 2 years ago
I could actually submit a PR for that, but I'm new to vim. If it works for you, let me know.
It's too invasive for a language server plugin to start a server automatically when it hasn't even opened an associated code file. Is that what you're suggesting, that a server is started even when vim is in e.g. a .html file?
I put it this way: if vim is opened without file argument in a directory where exists a solution file, then we could assume that the sever will be eventually started anyway. It could be an opt-in behavior via some option.
btw I understand that the exact condition for starting a server could be user-chosen, I just wanted to know if you are interested in having some option to do so and enabling some solution-wide commands in this case.
Not an option to do it automatically, I don't think that's a good way to go, it'll be too big a load on a vim instance, constantly searching for solution files up the directory tree every time a buffer is opened.
But making the :OmniSharpStartServer
and :OmniSharpFindType
commands global could be doable. It's just going to be a bit involved because all of the current server-management logic is buffer based. Each .cs buffer knows which server is it running under etc.
It looks like even if we ask user to choose a solution file manually, we end up with a single server running that will be reused for all subsequent buffers created. Am I right?
No, that shouldn't be the case, unless there actually is no .sln above the current buffer.
So currently with .cs files, when the buffer is opened OmniSharp-vim searches up the directory tree for a .sln (or .csproj, if no .sln is found). It checks to see if that .sln already has a server running. If it does, it attaches to that server, otherwise it starts a server.
By the way @starteleport, although the commands aren't available from non-csharp buffers, the functions that they call are. So you can already do this from any buffer:
:call OmniSharp#StartServer() " :OmniSharpStartServer
:call OmniSharp#actions#symbols#Find() " :OmniSharpFindSymbol
:call OmniSharp#actions#symbols#FindType() " :OmniSharpFindType
Thanks, that's the solution I've ended up with!
I want to be able to navigate to type when I've just opened the workspace.
I suggest adding the option to automatically start server when there is solution file in global working dir and enable
:OmniSharpFindType
and:OmniSharpFindSymbol
.