ligershark / Kulture

Sublime extension for ASP.NET vNext
Other
236 stars 30 forks source link

C# Intellisense #12

Closed shirhatti closed 9 years ago

shirhatti commented 10 years ago

C# Intellisense

Investigating using Roslyn (In-memory C# compiler) and DesignTimeHost to provide code completions in Sublime

Initial Prototype

Initial prototype lives at SublimeSharp

C# Intellisense

jchannon commented 10 years ago

To confirm we need the WebAPI app running in the background to get the plugin to give output?

shirhatti commented 10 years ago

Yes. The API should run at http://localhost:5000

The plugin.py should be added to your packages directory

This is a Windows-only prototype at the moment

shirhatti commented 10 years ago

@jchannon I wrote a Powershell one-liner that makes installing the Sublime Plugin easier

(Invoke-WebRequest http://shirhatti.com/Plugin.sublime-package).Content >((Get-ChildItem Env:APPDATA).Value + '\Sublime Text 3\Installed Packages\Plugin.sublime-package')

To remove the Plugin

Remove-Item ((Get-ChildItem Env:APPDATA).Value + '\Sublime Text 3\Installed Packages\Plugin.sublime-package')

Edit

If you want to try it out without running the WebAPI try

Mac

wget http://shirhatti.com/Pluginnobackend.sublime-package -P ~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages

Windows

(Invoke-WebRequest http://shirhatti.com/Pluginnobackend.sublime-package).Content >((Get-ChildItem Env:APPDATA).Value + '\Sublime Text 3\Installed Packages\Plugin.sublime-package')
glennblock commented 10 years ago

Nice progress @shirhatti!

jchannon commented 10 years ago

Nice!

I'm wondering if we try and get this working via Omnisharp as that has all the functionality we need at the moment. Its tied to NRefactory though so there would be effort needed to move Omnisharp across to Roslyn once that is complete.

Thoughts?

UPDATE: There is currently this https://github.com/moonrabbit/OmniSharpSublime but @nosami had to hack it to work and some of the features don't seem to work but the base is there. Do we try and get that into a stable state?

Mpdreamz commented 10 years ago

HI Guys I would love this.

I did some work try to port the typescript plugin for sublime from 2 to 3. It followed the exact same approach: typescript language services hosted somewhere and using HTTP to get errors/intellisense suggestions.

OmniSharpServer follows the same paradigm, I love the work @nosami did but his initial estimations are that its quite some work

https://github.com/nosami/OmniSharpServer/issues/75

Maybe the two projects could benefit from a common API ?

nosami commented 10 years ago

NRefactory has already started to implement intellisense using Roslyn - see https://github.com/icsharpcode/NRefactory/blob/roslyn/ICSharpCode.NRefactory.CSharp/Features/Completion/CompletionEngine.cs and they are making headway on rewriting their automated code issues / refactorings.

It's actually quite simple - but there is no point in making the switch over until the refactorings are ported over to Roslyn. OmniSharp server gives you much more than intellisense - https://github.com/nosami/OmniSharpServer/tree/master/OmniSharp

If I made the switch over to using the Roslyn branch of NRefactory now, you would lose quite a bit of functionality.

If I dropped the NRefactory dependency and switched over to Roslyn, the OmniSharp server would be much simpler than it is now I think, but it wouldn't have any refactorings.

At this moment in time, the only way to get the best of both would be for OmniSharp to have two ASTs in memory for each file, the Roslyn version and the NRefactory version. That seems a little excessive, although doable.

Really I think the best solution is to just wait for NRefactory to finish their porting work. Then OmniSharp server should just work against Roslyn without too many changes. I won't be changing any of the public API regardless.

nosami commented 10 years ago

I should probably add that you can already do Asp.Net vNext programming with https://github.com/nosami/Omnisharp and https://github.com/sp3ctum/omnisharp-emacs today :)

If I were a Sublime user, I'd build it myself. I estimate a couple of days work to get all features into the client.

The only downside (?) is that it's not using Roslyn (yet).

glennblock commented 10 years ago

@nosami very cool to see this. Shameless plug but scriptcs users would definitely love this.

shirhatti commented 10 years ago

@nosami I wasn't aware that NRefactory has started to use Roslyn. I agree with your assessment that the best solution is to wait for NRefactory to finish their porting work. I will try to use your public API on my Sublime extensibility so as to best leverage your awesome work with OmniSharp. Can you link me to your API documentation?

@astralhpi Do you have any plans to implement this with moonrabbit/OmniSharpSublime ?

+cc @sayedihashimi @shanselman for thoughts?

jchannon commented 10 years ago

@shirhatti OmniSharpSublime already uses OmniSharp it just needs a bit of polish as @nosami and I had to hack it to get it working with Sublime

alt

nosami commented 10 years ago

@shirhatti I'm afraid I don't have any documentation but it's not too difficult to work out.

You just need to start the server using the instructions here https://github.com/nosami/OmniSharpServer

This is an early version of a POC that me and @PaulCampbell built for sublime - https://github.com/PaulCampbell/OmniSharpSublimePlugin/blob/efb9fd8a66e5b75ac8647685b28edf86066331bc/OmniSharp.py

The @moonrabbit version is nicer code, but I think this illustrates better how to interact with the server. This code is using standard form posts (x-www-form-urlencoded) to make a request to the server, but you can also send the parameters as a JSON object if you prefer.

If you don't care about getting documentation for each completion result (uses MonoDoc on *nix which is slow) then you probably want to add :-

parameters['WantDocumentationForEveryCompletionResult'] = false

The OmniSharp code is broken up into a feature per folder (almost). You can figure out the requests by looking at the Request.cs in each folder, e.g. https://github.com/nosami/OmniSharpServer/blob/master/OmniSharp/AutoComplete/AutoCompleteRequest.cs

jchannon commented 10 years ago

Also we need to consider the current ST3 plugin wants a sln file but we know it works for ASPNet vNext by just passing the folder path. This was part of the hack we did to get it working

sayedihashimi commented 10 years ago

Adding @davidfowl to see if he has thoughts on this?

jchannon commented 10 years ago

I've created a PR for the ST3 plugin so we don't have to hack it to work https://github.com/moonrabbit/OmniSharpSublime/pull/5

jchannon commented 10 years ago

I've been in touch with https://dotnetfiddle.net/ who provide intellisense in the browser. They use Roslyn apparently and I have managed to convince them to OSS their intellisense code so we can take a look https://twitter.com/sergey_litvinov/status/497391229068247041

davidfowl commented 10 years ago

Omnisharp won't work by itself, you'll need to run the design time host since we don't use csproj files.

nosami commented 10 years ago

Omnisharp doesn't need csproj files either.

On Thu, Aug 7, 2014 at 4:23 PM, David Fowler notifications@github.com wrote:

Omnisharp won't work by itself, you'll need to run the design time host since we don't use csproj files.

— Reply to this email directly or view it on GitHub https://github.com/ligershark/Kulture/issues/12#issuecomment-51487119.

jchannon commented 10 years ago

@davidfowl we already have vnext nancy app working without csproj with omnisharp

sayedihashimi commented 10 years ago

Visual Studio uses this same Design Time Host that @davidfowl mentions. If we can hook that up 👆 o it's likely to be the best option.

We have worked on a prototype and make some progress already.

@Shirhatti can you give an update on DTH and describe what it will take to enable IntelliSense with it?

davidfowl commented 10 years ago

It's not the best option it's really the only option. The design time host is the way to get the lost of resolved references, source files, compilation settings etc from a vnext project system. Anything else you do would be an estimation and would probably be inaccurate.

You can get the same effect by running through the vnext runtime's code paths but that's exactly what the design time host does.

nosami commented 10 years ago

@davidfowl Sounds great. I should integrate that with OmniSharp from the sound of it. I wondered how to deal with that.

shirhatti commented 10 years ago

Adding this for reference. DTH output- https://gist.github.com/shirhatti/2a76b9cba1e9a9f0aed1

nosami commented 10 years ago

Does the DTH work outside of Windows?

davidfowl commented 10 years ago

There's a bug somewhere because of a missing socket ctor. But we should be able to make that work well.

sayedihashimi commented 10 years ago

FYI my hope is that we can leverage DTH for most of the heavy lifting and then we include a thin layer to integrate into Sublime. That way others can look at the Sublime Extension and then add support in other editors. Hopefully we can make it really easy to snap ASP.NET vNext into any toolset.

jchannon commented 10 years ago

So do we need to make some decisions of the route we're taking and how we'll achieve intellisense, refactoring etc?

davidfowl commented 10 years ago

The way I see it there's 3 major pieces:

The project system has information about the relationships between projects, and has information about each project (references, configurations, source files etc). It can also give you errors and warnings. (Design time host)

The intellisense engine takes information from the project system and is aware of open buffers and can produce a set of "completions" for a particular type (and maybe other things like refactoring). (NRefactory/Rosyln Workspaces)

The editor can popup UI at the appropriate place and talk to the intellisense engine about the active buffer and project and show the right suggestions in the right place. (Sumblime python thingy)

Mpdreamz commented 10 years ago

Genuine question out of interest on the direction this discussion is going:

Is there going to be a "new OmniSharpServer" specifically for the vNext ecosystem blessed by the asp.net team or are we looking to integrate with OmniSharpServer ?

Not claiming to have the wisdom to know which direction is the best but my gut feeling is that integrating with OmniSharpServer should at least be explored.

davidfowl commented 10 years ago

The only vNext specific piece is the design time host. Ideally the ominsharp server would have an adapter model for getting information from the project and we would just plug into it. Everything else should just work.

sayedihashimi commented 10 years ago

What's the best way for us to make progress here? How about a conf call or jabbr group chat?

FYI I'm on vacation this week so I'm a little slow 🐌 now but will pick up pace when I'm back.

jchannon commented 10 years ago

I'm easy but I'm away w/c 13th Aug but I should think @nosami is the main man for this :smile:

nosami commented 10 years ago

Jabbr group chat sounds like a good idea to me.

sayedihashimi commented 10 years ago

Ok thanks I'm back from vacay 8/19, I will work with you guys when I get back on setting up the group jabber chat.

cc @davidfowl @Shirhatti @shanselman @madskristensen

sayedihashimi commented 10 years ago

Ok I will try and setup tome for us to meet on jabbr on Friday 8/29. Who are the required attendees? I'm thinking the following list.

How about 4PM Pacific Time on 8/29? If that time doesn't work please reply back with your time zone and available times.

nosami commented 10 years ago

It's fine with me although a little late. I'm on GMT time so that will be midnight here.

jchannon commented 10 years ago

Same as Jason too so would be a bit late and I need my beauty sleep :wink:

sayedihashimi commented 10 years ago

OK how about 8/29 1PM Pacific Time? Is that too late? If so I'll look for some alternate times around 11AM next week. Which is best for you guys?

nosami commented 10 years ago

1PM Pacific Time is fine for me on any day other than Friday :)

sayedihashimi commented 10 years ago

I will find a time that works for @davidfowl and myself for next week and proppse here soon.

sayedihashimi commented 10 years ago

OK how is Wed 9/3 at 12PM Pacific Time? I've proposed that time to @davidfowl and @shanselman.

shirhatti commented 10 years ago

I can't do Wednesday mornings. I can do Tuesday or Thursday mornings. If Wednesday works for everybody else I'll sync up with @sayedihashimi offline

jchannon commented 10 years ago

Wed is fine for me

nosami commented 10 years ago

Wednesday is fine, as is any other day Mon-Thurs

sayedihashimi commented 10 years ago

@shirhatti that would be Wed afternoon for you, either 2PM or 3PM depending on timezone.

@nosami @jchannon what do you think of doing a Skype video chat? @shanselman was suggesting that as an option over jabbr. Thoughts?

jchannon commented 10 years ago

Yup fine by me :smile:

nosami commented 10 years ago

Sure, Skype is fine.

Mpdreamz commented 10 years ago

I didn't make the required list but would love to be able to eavesdrop, pitch in if at all possible. If there is a spot on the skype chat I would love to join.

sayedihashimi commented 10 years ago

@Mpdreamz this is a community effort so everyone is welcome. The required list was to identify the folks we can't make progress without.

@shanselman is there a limit on the number of attendees on Skype? How should these guys get the info to join?

shanselman commented 10 years ago

I think the limit is 25 people for a Skype Group call. Post your Skype names.