OmniSharp / omnisharp-vim

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

support for unimported types #720

Open ton190 opened 3 years ago

ton190 commented 3 years ago

In Visual Studio you get suggestions for all types, even if they are not imported. How to do it in omnisharp-vim?

nickspoons commented 3 years ago

I don't know about Visual Studio, but VScode (which uses the same language server as OmniSharp-roslyn) has moved to a new completion engine, which does this. I'd like us to move to the new engine too but it's not trivial, unfortunately.

So, it's a matter of someone finding time to do the work. It's a great feature though, it'll be cool to get it working here.

ton190 commented 3 years ago

Thank you for explanation. Only 4 thinks are missing in vim for c#

  1. Unimported types support
  2. Razor Pages support
  3. Break Points
  4. .resx files support

Hope it will be implemented at some point in future.

nickspoons commented 3 years ago

If you're using dotnet core, you can debug with breakpoints using vimspector, which I've only used a couple of times so far (most of my work projects are .Net Framework) but it works really well.

ton190 commented 3 years ago

Thanks. Did not know about this plugin.

nickspoons commented 3 years ago

You're welcome. I think we might as well leave this issue open, getting un-imported types supported is a valid thing to track.

Kevinizevbigie commented 2 months ago

Hi @nickspoons, is unimported type support still on the roadmap? thanks

nickspoons commented 2 months ago

@vinn2010 It is already supported to a certain extent, if you enable it in OmniSharp-roslyn with the EnableImportCompletion option in ~/.omnisharp/omnisharp.json, i.e.:

{
   "RoslynExtensionsOptions": {
      "AnalyzeOpenDocumentsOnly": false,
      "EnableAnalyzersSupport": true,
      "EnableDecompilationSupport": true,
      "EnableImportCompletion": true
   }
}

This makes unimported types appear in completions, e.g. Console will be presented as a completion option for Conso when you don't have using System;. However, OmniSharp-vim does not automatically add the missing using statement when you select the option, and the completion option does not have completion documentation included until the using statement is added. In most cases you'll be able to do it with a quick :OmniSharpFixUsings after the completion.

The ideal functionality here would be to insert the using automatically. However realistically it is unlikely that I'll get around to doing it. Happy to merge a good PR, although as I said earlier, it's not trivial.

Kevinizevbigie commented 2 months ago

Very useful. I wasn't aware of OmniSharpFixUsings, this is really all I need by doing:

" Add usings on save
autocmd BufWritePost *.cs OmniSharpFixUsings