omnisharp-emacs icon indicating copy to clipboard operation
omnisharp-emacs copied to clipboard

We need a company-mode interface to autocompletions with import statements

Open mikavilpas opened this issue 11 years ago • 9 comments

Hey guys, good news.

I implemented completing stuff from non-imported namespaces, and it works great.

But I only did this for the popup and ido display functions. We need someone to implement the functionality for company-mode as well.

Here's the gist of it:

  • there is a new setting called omnisharp-auto-complete-want-importable-types which holds the user's preference on including them on normal, "everyday" completions
  • when the setting is t, the server will respond with a new RequiredNamespaceImport property in the AutoCompleteResponse. This needs to be put to the beginning of the current file so imports stay in sync.
  • for that purpose I made a new function, omnisharp--insert-namespace-import which takes the value of the RequiredNamespaceImport property (typically e.g. "System.IO") and inserts "using System.IO;" at the very first line of the file. There is even a test for this =)

I'm happy with the result. Inserting the namespace doesn't disrupt the user in any way since point doesn't move at all. It's completely transparent. Friday evening well spent!

@bbbscarter @nosami

mikavilpas avatar Aug 15 '14 21:08 mikavilpas

Also, boring maintaining tasks:

  • update README.md when company-mode stuff is ready
  • promo pic!
  • increment version number when merging

mikavilpas avatar Aug 15 '14 21:08 mikavilpas

Oh wow! That sounds very cool :)

I'll try and see if I can get it working some time over the weekend unless @bbbscarter beats me to it! I suspect that he could do it much more quickly than I could ...... but I like a challenge :)

nosami avatar Aug 15 '14 21:08 nosami

Did you know that there is an NRefactory helper method to add a using statement (and keep them in the correct order) ?

https://github.com/nosami/OmniSharpServer/blob/master/OmniSharp/CodeActions/FixUsingsHandler.cs#L249

nosami avatar Aug 16 '14 00:08 nosami

fyi - I'm very unlikely to look at this over the weekend. Maybe, one night during the week, but don't count on it.

nosami avatar Aug 17 '14 11:08 nosami

Don't stress it :)

Nobody will ask their money back.

On 17.08.2014 14:26, Jason Imison wrote:

fyi - I'm very unlikely to look at this over the weekend. Maybe, one night during the week, but don't count on it.

— Reply to this email directly or view it on GitHub https://github.com/sp3ctum/omnisharp-emacs/issues/101#issuecomment-52419431.

mikavilpas avatar Aug 17 '14 13:08 mikavilpas

As company-mode completes automatically without pressing a keybinding, I propose that a separate function is created that applies the inverse of omnisharp-auto-complete-want-importable-types.

Does that make sense?

nosami avatar Aug 17 '14 21:08 nosami

Sorry for not chiming in earlier, busy week.

I’ll try and get some time this week to look at both of these!

On 17 August 2014 at 22:18:04, Jason Imison ([email protected]) wrote:

As company-mode completes automatically without pressing a keybinding, I propose that a separate function is created that applies the inverse of omnisharp-auto-complete-want-importable-types.

Does that make sense?

— Reply to this email directly or view it on GitHub.

bbbscarter avatar Aug 17 '14 21:08 bbbscarter

@nosami Yeah, good idea.

2014-08-18 0:35 GMT+03:00 bbbscarter [email protected]:

Sorry for not chiming in earlier, busy week.

I’ll try and get some time this week to look at both of these!

On 17 August 2014 at 22:18:04, Jason Imison ([email protected]) wrote:

As company-mode completes automatically without pressing a keybinding, I propose that a separate function is created that applies the inverse of omnisharp-auto-complete-want-importable-types.

Does that make sense?

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/sp3ctum/omnisharp-emacs/issues/101#issuecomment-52435940 .

mikavilpas avatar Aug 18 '14 07:08 mikavilpas

not available on the roslyn server, WantImportableTypes is ignored.. postponing

razzmatazz avatar Nov 19 '17 17:11 razzmatazz