Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe default formatting options #9

Open
Evangelink opened this issue Dec 9, 2020 · 15 comments · May be fixed by #10
Open

Describe default formatting options #9

Evangelink opened this issue Dec 9, 2020 · 15 comments · May be fixed by #10

Comments

@Evangelink
Copy link

Hello,

I am new to using this extension and I have just noticed that there is no description for the entries under Visual Studio 2019 options:

image

@deviousasti
Copy link
Member

I've been meaning to put that in for some time, although it's not very useful without concrete examples for before and after.
The options are here:
https://github.com/fsprojects/fantomas/blob/master/docs/Documentation.md

Do you have any good suggestions?

@Evangelink
Copy link
Author

Ideally, having the description and a dynamic example which changes based on the value of the setting as it is done for ReSharper or C# code styles.

image

image

I would be happy to help here, this way I could learn the options and see if I want some tweaks to the default configuration :)

@deviousasti
Copy link
Member

Any sort of help is appreciated!
These are the default options to be used if there's no .editorconfig file.

This is where the descriptions are specified.
https://github.com/deviousasti/fsharp-formatting-for-vs/blob/bdb75fa49d01a3eb5b6f6a84ad5dcb71a634ca16/src/FantomasOptionsPage.cs#L204

@Evangelink
Copy link
Author

Let me dive back into VS option pages (I haven't used them in a while).

@deviousasti deviousasti changed the title No description in VS2019 Describe default formatting options Dec 10, 2020
@deviousasti
Copy link
Member

If you're free this weekend, we can work together on this. VS live share session?

@Evangelink
Copy link
Author

Sorry @deviousasti I missed this notif, I might have some availability next week-end or at evening (CET timezone).

@Evangelink
Copy link
Author

Regarding the Description, most of the entries are missing the [Description(XXX)] attribute which explains why there is no example.

I am still trying to find how to have the dynamic code example, looking at roslyn and some other repositories we might have to use a WPF page instead of WinForms.

@deviousasti
Copy link
Member

Oh, sorry, I forgot to explain.
We're using this attribute to specify that VS needs to use this as an options page:

https://github.com/deviousasti/fsharp-formatting-for-vs/blob/bdb75fa49d01a3eb5b6f6a84ad5dcb71a634ca16/src/FantomasVsPackage.cs#L27
Which shows up the options in a property editor.

Adding a description attribute is one step forward, but it isn't sufficient for the Roslyn like experience.
We're going to have to recreate the configuration UI (checkboxes, dropdown, etc) in a WPF UserControl, and then add a set of examples for the options.

I've been working with WPF for 10 years now, so not a big deal.
If we add a custom attribute for the corresponding .editorconfig option, we can have a nice UI to generate an .editorconfig file as well.

@Evangelink
Copy link
Author

Yeah the only problem for me so far is just to be able to include a TextEditor like component which will reuse all the formattings and colors from the F# configuration in the IDE. Maybe I am going a little too far and we could simply start with just a simple text (no colors + no IDE specific background color).

@deviousasti
Copy link
Member

Yeah, that's probably a bit extreme for now. I have seen other extensions use AvalonEdit for displaying code, but that's a lot of stuff for this one feature.

If the examples are simple enough, coloring needn't be an issue.
Although... we're dependent on FCS and have to parse the examples anyway, so we could probably assign a colour per token, and it would be reasonable.

@nojaf
Copy link
Contributor

nojaf commented Dec 14, 2020

Hey Asti, I'm afraid I can't really add anything useful here.

Rider uses a custom editorconfig parsing thing, they added attributes for each setting as well: https://github.com/JetBrains/fsharp-support/blob/93ab17493a34a0bc0fd4c70b11adde02f81455c4/ReSharper.FSharp/src/FSharp.Psi/src/CodeFormatter/FSharpFormatSettingsKey.cs

Ionide does not have any UI for the settings.

Fantomas Online has a copy settings button when you change the defaults from the menu.
Example
That copies the .editorconfig settings to the clipboard.
But again no description.

@Evangelink
Copy link
Author

@deviousasti How would you like to proceed, I start some PR and we contribute together?

Also I am wondering if you want to hardcode the various properties or if you want to actually read some configuration file and dynamically generate the settings page?

@deviousasti
Copy link
Member

deviousasti commented Dec 16, 2020

Well, no we can have some custom attribute on each property and use reflection to generate our UI.

Yeah the only problem for me so far is just to be able to include a TextEditor like component

I made this so we can have our cake and eat it too.

https://github.com/deviousasti/fsharp-highlighting

@deviousasti
Copy link
Member

deviousasti commented Dec 16, 2020

As for your branch, would I have commit access?

@Evangelink
Copy link
Author

Evangelink commented Dec 16, 2020

Sure!

That's a really nice idea you had to create a separate project for the highlighting, this will make it easier to share this across the F# tools.

@Evangelink Evangelink linked a pull request Jan 5, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants