dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.92k stars 786 forks source link

Suggestion: support F# Snippets #1498

Open GeertVL-zz opened 8 years ago

GeertVL-zz commented 8 years ago

After a discussion with @madskristensen and he was not sure that snippets are actually supported in Visual Studio 2015 I want to ask it here to clear out if there actually supported or not. Or just not implemented and it has to become feature (where I gladly want to help out with).

Who knows for sure what the deal is with F# snippets in Visual Studio 2015. It is supported in te Python tools and all other environment but replicating it in F# does not work.

Who can help me? @dsyme @tpetricek ...

Thanks!

KevinRansom commented 8 years ago

@GeertVL This is a great question, and very timely. @OmarTawfik is close to finishing up the foundational work to get the F# editor building on Roslyn Workspaces, and @brettfo has Joined the F# team, welcome Brett, he is an expert in the Roslyn IDE having worked on it, for pretty much as long as there has been a Roslyn IDE.

I think @GeertVL that you and @brettfo should hook up and figure out how you can best contribute.

Kevin

GeertVL-zz commented 8 years ago

@KevinRansom where can I find the foundational work @OmarTawfik is working on.

And @brettfo nice that you joined the F# team. How can I help? I am eager to learn, to work and get a wicked IDE for F#.

KevinRansom commented 8 years ago

@GeertVL It's in the Roslyn branch.
https://github.com/Microsoft/visualfsharp/tree/roslyn

It is building a roslyn workspaces layer that uses the F# language service. In essence it is very similar to how TypeScript uses the Roslyn editor.

brettfo commented 8 years ago

@GeertVL, you mentioned that

It is supported in the Python tools and all other environments but replicating it in F# does not work.

Can you give me an example (or pointer to code) of what you've tried so far?

GeertVL-zz commented 8 years ago

@brettfo I tried to add a folder to the INSTALLROOT (visual studio installation path) like so: FSharp\Snippets\1033\ with SnippetsIndex.xml in the root and I used this LanguageGuid {bc6dd5a5-d4d6-4dab-a00d-a51242dbaf1b} and then some snippets.

I created a package with the attribute ProvideLanguageCodeExpansion. It appears in the dropdownlist of the Code Snippets Manager of Visual Studio 2015 but the snippets do not appear in the intellisense dropdown.

Do I need to implement it exactly as the Python Tools with the custom ProvideCodeExpansionsAttribute class? Can I create a separate package for the snippets or do I need to include it in the visualfsharp (this repo) package to make it work?

How is F# exactly called in VS2015? Is it F#, FSharp, Visual F#, ... as I could not find the exact name?

GeertVL-zz commented 8 years ago

@brettfo @KevinRansom to show what I have done based on the Python tools you can see it in my repo https://github.com/GeertVL/FSharpSnippets

Pilchie commented 8 years ago

Hi @GeertVL,

Each language populates IntelliSense on it's own, so you would definitely need to change the built in F# completion code to add snippets there. However, with your existing setup it is possible that the Edit->Insert Snippet command would start working. That's probably the first step.

GeertVL-zz commented 8 years ago

Ok that is why Python Tools reimplements the intellisense. Is it extensible? Or do I need to add it to the core project? Where is the intellisense provider situated?

brettfo commented 8 years ago

As a follow-up to those interested, I've been looking into adding proper snippet support for F# in Visual Studio by mimicking what the Python folks do (e.g., see here). I'm still a ways out since there's much more to do than just implementing/applying some attributes, but it is coming along. When my changes are in a better state I'll share my progress here for others to follow along.

Edit: I'll be doing my work here but this comes with the standard warning that nothing here is ship-quality until I make a PR and I offer no guarantees that I won't regularly force-push here; history will be meaningless for a while.

brettfo commented 8 years ago

I've added an initial PR to continue this discussion in #1527.

xperiandri commented 8 years ago

@GeertVL, have you seen this and this repo (http://fsharpcodesnippet.codeplex.com/) It is not as modern and I also hope that F# snippets will be a regular part of IDE without any extensions and hacks. The author, Tao Liu is an MSFT employee as far as I know

realvictorprm commented 6 years ago

ping, I like snippets.

xperiandri commented 2 years ago

It would be nice to finally have them. Major of possible variants are collected in https://github.com/xperiandri/CodeRushTemplates

dsyme commented 2 years ago

@KathleenDollard Here's another VS feature for the slate