OmniSharp / omnisharp-vim

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

omniSharp-vim not working #798

Closed redjoker011 closed 2 years ago

redjoker011 commented 2 years ago

Hello, I'm installing omnisharp-vim in my workstation but I the auto completion is not working as well as other omnisharp commands aside form OmniSharpInstall and OmniSharpOpenLog

Screen Shot 2022-07-15 at 2 35 18 PM

Platform: MacOS M1 Neovim Version: v0.8.0-dev-nightly-246-g977790746

Vim config

Screen Shot 2022-07-15 at 2 46 59 PM

The installation was successful, but the log is empty as well as the commands are not available

Installation

Screen Shot 2022-07-15 at 2 34 57 PM

Log

Screen Shot 2022-07-15 at 2 38 12 PM

Debug Mode

Screen Shot 2022-07-15 at 2 40 21 PM

Here Omnisharp is using Omnisharp.exe Is this correct ?

nickspoons commented 2 years ago

There's a lot going on here!

First of all, I'd recommend paring down your omnisharp config. The g:OmniSharp_proc_debug isn't generally very useful and actually stops some proper logging from happening, so remove that.

Now, what kind of project are you working on? If it's a unity project it will be .NET Framework, otherwise is it .NET Framework or dotnet core? Actually either way it would be worth trying the new net6 version of the server, but especially if you're running dotnet core projects. (For some background, OmniSharp-roslyn has been a .NET Framework project requiring mono to run on mac and linux until quite recently, but there is now a dotnet native build available which seems to be superior in all situations I've tried - but I haven't tried a Unity project so it's possible the old .NET Framework+mono still works better for those).

To install the net6 version, remove g:OmniSharp_server_use_mono from your init.vim and add let g:OmniSharp_server_use_net6 = 1 instead. Then restart vim and :OmniSharpInstall to download the correct version. Then open your project and report with the log.

nickspoons commented 2 years ago

Here Omnisharp is using Omnisharp.exe Is this correct ?

Yes, this was correct in this situation. The executable was being launched by mono which is as expected with this config.

redjoker011 commented 2 years ago

Hi @nickspoons , thanks for your response. Well basically I've just started exploring c# and .Net so I have a Visual Studio installed in my end. Mostly following tutorials from Microsoft. I've tried you're suggestion to use net6 as language server

Change the config and reinstall omnisharp:

Screen Shot 2022-07-15 at 6 43 50 PM Screen Shot 2022-07-15 at 6 44 00 PM

Restart vim and omnisharp pop up installation appear:

Screen Shot 2022-07-15 at 6 44 37 PM

Encountered a weird error upon opening a .cs file which link was redirected to installation page

Screen Shot 2022-07-15 at 6 44 48 PM

Do the installation again even though I already have dotnet installed via visual studio and still encountered the same error

redjoker011 commented 2 years ago

:OmniSharpOpenLog command displays the ff. info which states that the server successfully started but autocompletion and suggestions still not working

Screen Shot 2022-07-15 at 6 57 26 PM

Omnisharp commands still not working though

Screen Shot 2022-07-15 at 7 00 43 PM
redjoker011 commented 2 years ago

Running the executable where omnisharp is installed give more details about the issue which seems like a build compatibility. Does this mean OmniSharpInstall fails to install correct build for MacM1 ?

Screen Shot 2022-07-15 at 7 03 41 PM
nickspoons commented 2 years ago

Does this mean OmniSharpInstall fails to install correct build for MacM1 ?

I don't know exactly. There's something fishy but I can't tell if it's OmniSharp-vim's installer, OmniSharp-roslyn, or your environment. I don't have an M1 so can't help much with debugging, but I believe omnisharp does work on them. Try downloading an osx-arm64-net6 build from https://github.com/OmniSharp/omnisharp-roslyn/releases and try running the OmniSharp exe.

nickspoons commented 2 years ago

Do the installation again even though I already have dotnet installed via visual studio

Just to clarify, :OmniSharpInstall is not installing dotnet, in fact it's not really "installing" anything at all, it just downloads an OmniSharp-roslyn release and extracts it to ~/.cache/omnisharp-vim/omnisharp-roslyn

redjoker011 commented 2 years ago

Already resolved the issue 🎉 . In my case I have 2 binaries installed in/usr/local/share/dotnet and /usr/local/share/dotnet/x64. Based on /etc/dotnet/install_location the default install location was in /usr/local/share/dotnet/x64 which is quite confusing so I uninstall dotnet using the ff. command

 sudo rm -r /usr/local/share/dotnet && sudo rm -r /etc/dotnet

Reinstall latest dotnet sdk for Arm64

and point dotnet root to where the sdk were installed which is in /usr/local/share/dotnet.

Add this to your shell configuration .zsh,.bash,.config.fish

export DOTNET_ROOT=/usr/local/share/dotnet
Screen Shot 2022-07-15 at 10 00 15 PM

Thanks for your assistance @nickspoons. Please feel free to close this issue whenever needed

nickspoons commented 2 years ago

Glad to hear you're up and running now!

adoreparler commented 1 year ago

I had the similar error

I installed dotnet through homebrew

➜  which dotnet
/opt/homebrew/bin/dotnet

vimrc:

...
let g:OmniSharp_server_display_loading = 1
let g:OmniSharp_server_use_net6 = 1
let g:OmniSharp_loglevel = 'debug'

I hadd to add

export DOTNET_ROOT="$HOMEBREW_PREFIX/opt/dotnet/libexec"

to my .zshrc to get it to work

then it all started working