OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.7k stars 168 forks source link

Constantly getting could not find solution file or directory to start server on small .Net Core project #424

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello!

Newbie to C# - I was trying to do a simple hello world like rest api with .Net Core, and have been stuck with this error constantly popping up a bit after I open a CS file.

Could not find solution file or directory to start server

Thought .Net Core projects were supported by omnisharp roslyn and omnisharp vim after reading https://github.com/OmniSharp/omnisharp-vim/issues/269?

What I was doing

Installation info

Linux mint 19

dotnet --info output image

Mono version image

Thanks!

ghost commented 5 years ago

I forgot to mention:

  1. I have vim 8.1.490.
  2. Installed omnisharp roslyn 1.32.1 explicitly as specified on the README
  3. set g:OmniSharp_server_path to point to my omnisharp roslyn installation directory.
  4. Using let g:OmniSharp_server_use_mono = 1
nickspoons commented 5 years ago

When you say you installed OmniSharp-roslyn as described in the README, does that mean you let vim do it, with :OmniSharpInstall?

axvr commented 5 years ago

I think you probably need a solution file, you can create one using dotnet new sln, once added, you will have to add all of the *.csproj files to it by using dotnet sln add <path-to-csproj-file>.

See dotnet sln -h and dotnet new sln -h for more info.

ghost commented 5 years ago

Ah, sorry. Should've made that clearer @nickspoons

  1. I tried that :OmniSharpInstall 'v1.32.1' - but I noticed that it would say installation was done in like 10 seconds, and I noticed in another issue somewhere you saying it takes 15 minutes+ on Windows? I also noticed that it would just have a tarball of omnisharp http mono version in my .omnisharp/omnisharp-roslyn directory, so I gave up on this approach.

  2. I ended up following the Manual installation section - I downloaded the http version for linux x64 under release 1.32.1 though since the section above it had that note about the latest roslyn versions not accepting http requests.

ghost commented 5 years ago

@axvr - ah, ok. The tutorials I had followed online had made of no mention of adding a solution.

That said, it looks like autocomplete doesn't work? I turned YCM back on with its cs completion disabled (I in fact installed YCM without --cs-completer option explicitly, actually) and with omnisharp on, but when I type in String. for example, none of the static methods in https://docs.microsoft.com/en-us/dotnet/api/system.string.compare?view=netcore-2.1 pop up.

I read in a few issues + README that omnisharp vim provides its autocompletes through omnicomplete? YCM says it picks up omnifuc based completes, so thought it'd work, guess not. :|

nickspoons commented 5 years ago

I was just writing the same thing as @axvr, to try to add a dotnet sln.

Don't worry about the 15m thing, I think that was a github issue, usually it's fast. Anyway you're obviously using WSL so it's doing a Linux install - for all vim and O# know, you're on Linux.

YCM works on its own OmniSharp-server using the legacy server, it won't work with dotnet. Disable it.

nickspoons commented 5 years ago

Once O# is running, you can trigger OmniSharp's omni-completion manually using <C-x><C-o>. If you want autocompletion you can use a plugin for that, like mucomplete.

ghost commented 5 years ago

Sorry if I wasn't clear - I don't have windows system for linux. I have a linux mint 19 installation that I'm trying to install this on.

Let me try nuking everything and reinstalling with the omnisharp vim's install command... one sec.

EDIT: @nickspoons - does omnisharp vim require other settings to use <C-x><C-o>? after a fresh install, I got past the other issues above. However, triggering omni completion returns nothing, and ~/.vim/bundle/omnisharp-vim/log/python.log is also empty.

ghost commented 5 years ago

Hi @nickspoons -

Looks like something is definitely up with my installation. Although that startup error no longer happens after I followed your direction of using the OmniSharp install command and the dotnet sln thing, I went through the doc and tried various commands - it seems like the majority of them do not work.

  1. OmniSharpNavigateUp and down - do nothing
  2. OmniSharpRename - ditto
  3. FindImplementations, FindUsages, ... all fail with TypeError: 'NoneType' object is not iterable, AttributeError: 'NoneType' object has no attribute 'get' for codeformat, ... when I look in the python.log file.
  4. As mentioned, complete with <C-x><C-o> does nothing.

Have you seen other folks with this kind of issue before? I find it odd that the majority of commands do nothing and also generate nothing in the python.log file.

nickspoons commented 5 years ago

The server is not running. So let's try some stuff.

First, remove the let g:OmniSharp_server_use_mono = 1 and g:OmniSharp_server_path bits from your .vimrc, and remove your ~/.omnisharp directory. Then restart vim and open a .cs file. OmniSharp-vim should see that you have no server installed and ask if it should download roslyn. Say yes - it will get the correct version (v1.32.1).

Check that the server has been downloaded and extracted correctly under ~/.omnisharp, then restart vim again and see if completion works (<C-x><C-o> - this is vanilla vim completion, nothing else required other than OmniSharp obviously). Note that it may take a few seconds for the server to start up silently in the background - keep trying completion for a couple of minutes.

If it's not working, try adding this to your .vimrc and restarting vim:

let g:OmniSharp_proc_debug = 1
let g:OmniSharp_loglevel = 'debug'

Now when you start vim and open a .cs file you'll get some info echoed at the bottom - it'll disappear but you can access it with :messages, please post the output here.

Posting your .vimrc would also be helpful.

The other thing that's always worth trying is just to run the server on its own, outside vim. From the directory where your .sln file is, run /home/yourusername/.omnisharp/run and post the output.

nickspoons commented 5 years ago

Note: Please make sure to remove the let g:OmniSharp_server_use_mono = 1 line before installing the server - this variable determines which server is downloaded.

ghost commented 5 years ago

Hi @nickspoons -

Done. Please note that I am trying this out on https://github.com/dotnet-architecture/eShopOnContainers this sample project.

It looks like reinstalling with server use mono and server path commented out from my vimrc didn't do much. I did make sure to comment these out first, nuke .omnisharp/ as well as the plugin itself by doing PluginClean in my vundle, and then re-installing the plugin and then the roslyn server.

image

With the debug levels I see that it's generating a message when I do <C-x><C-o> - that means a call out to /autocomplete endpoint got a 200 ok back in 29ms I'm guessing?

Anyway, in :messages output there's a metric s*** ton of Unable to resolve assembly messages. vim messages output.txt

Below is the content from my vimrc and cs.vim files (please note that the cs.vim content is copied & pasted at the very bottom) vimrc and csvim files.txt

ghost commented 5 years ago

I'm trying the steps above with the plan dotnet new webapi one as well - will post that in a minute.

ghost commented 5 years ago

Well that's interesting... the dead simple webapi after dotnet new webapi, dotnet new sln, and then dotnet sln add . works with autocomplete... image

The navigatedown command also successfully moves the cursor down to the next block.

Messages output:

DEBUG: 'Using vim job_start to start the following command:' DEBUG: ['/home/jhong/.omnisharp/omnisharp-roslyn/run', '-p', 49691, '-s', '/home/jhong/tmp/webapp/temp/temp.sln'] channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Http.Startup[0]' channel 0 open: ' Starting OmniSharp on linuxmint 19.0 (x64)' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Cake.CakeProjectSystem[0]' channel 0 open: ' Detecting Cake files in ''/home/jhong/tmp/webapp/temp''.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Cake.CakeProjectSystem[0]' channel 0 open: ' Could not find any Cake files' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Http.Startup[0]' channel 0 open: ' Project system ''OmniSharp.DotNet.DotNetProjectSystem'' is disabled in the configuration.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectSystem[0]' channel 0 open: ' Detecting projects in ''/home/jhong/tmp/webapp/temp/temp.sln''.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectManager[0]' channel 0 open: ' Queue project update for ''/home/jhong/tmp/webapp/temp/temp.csproj''' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Script.ScriptProjectSystem[0]' channel 0 open: ' Detecting CSX files in ''/home/jhong/tmp/webapp/temp''.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Script.ScriptProjectSystem[0]' channel 0 open: ' Could not find any CSX files' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Http.Startup[0]' channel 0 open: ' Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Http.Startup[0]' channel 0 open: ' Configuration finished.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.Http.Startup[0]' channel 0 open: ' Omnisharp server running on port ''49691'' at location ''/home/jhong/tmp/webapp/temp'' on host -1.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectManager[0]' channel 0 open: ' Loading project: /home/jhong/tmp/webapp/temp/temp.csproj' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectManager[0]' channel 0 open: ' Successfully loaded project file ''/home/jhong/tmp/webapp/temp/temp.csproj''.' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectManager[0]' channel 0 open: ' Adding project ''/home/jhong/tmp/webapp/temp/temp.csproj''' channel 0 open: '^[[40m^[[32minfo^[[39m^[[22m^[[49m: OmniSharp.MSBuild.ProjectManager[0]' channel 0 open: ' Update project: temp'

axvr commented 5 years ago

Unable to resolve assembly messages.

Did you make sure to run dotnet restore (to download the required dependencies) before opening Vim?

ghost commented 5 years ago

Ah, I thought I had done it, but I hadn't! Thanks. Closing this now - @nickspoons @axvr thanks for helping a .NET newbie out!

ghost commented 5 years ago

Hey @nickspoons - quick question. Do you guys have an autocomplete plugin you recommend for using side by side with YCM?

I disabled YCM for cs files by using their blacklist & completion disable by filetype options, but getting plugins like mucomplete, supertab, etc I didn't see a way to disable and only enable for CS files. I've been playing with deoplete (enable at startup = 0 in my vimrc, enable at startup = 1 in cs.vim) with the custom option of sources for cs set to omnisharp that I got from https://github.com/OmniSharp/omnisharp-vim/pull/392, but it seems like that also doesn't work with my installation.

Just curious if you know of other people who ran into this issue and what they did.

EDIT: ps - did you guys ever have an option for removing the scratch pad after autocomplete is done? Thought I saw one in sample vimrc section back when I was reading through this project a year or so ago, but I don't see one now. Maybe I'm misremembering...

nickspoons commented 5 years ago

Hi @JoeHTR,

I don't have a definitive answer for you - I don't use any autocompletion personally, just a mapping for <Tab> which triggers omnicompletion (a bit faster than hitting <C-x><C-o>).

Here's a suggestion for mucomplete, taken from lifepillar/vim-mucomplete#83:

autocmd BufEnter * if &ft ==# 'cs' | MUcompleteAutoOn | else | MUcompleteAutoOff | endif

To automatically remove the preview window (which is what gets opened with documentation results during completion) you could try this:

autocmd CompleteDone * if pumvisible() == 0 | pclose | endif

Ideally both of these should be inside an augroup

ghost commented 5 years ago

@nickspoons Doh, when I read mucomplete docs I interpreted MUcompleteAutoOn / MUcompleteAutoOff as turning the plugin firing automatically after a couple keystrokes feature on and off, not disabling mucomplete.

Still not working smoothly, but I'll figure something out from here. Thanks for the help!