Fsharp: Suggestion: support F# Snippets

Created on 27 Aug 2016  路  12Comments  路  Source: dotnet/fsharp

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!

Area-IDE Language Service Feature Request

All 12 comments

@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

@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#.

@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.

@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?

@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?

@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

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.

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?

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.

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

@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

ping, I like snippets.

Was this page helpful?
0 / 5 - 0 ratings