gmlewis / flutter-stylizer

Flutter Stylizer is a VSCode extension that organizes your Flutter classes and mixins in an opinionated and consistent manner.
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
Apache License 2.0
23 stars 3 forks source link

Is there way to run stylizer on all the files in a project? #6

Closed warriorCoder closed 3 years ago

warriorCoder commented 5 years ago

I'm curious to know if I can call this extension from the command line or better yet have a short cut key to style the code before saving.

Thanks so much!!

gmlewis commented 5 years ago

Hi @warriorCoder, that's an excellent question!

This is my first VSCode plugin and I don't actually know the answer.

I'll see what I can find out and then update this issue.

warriorCoder commented 5 years ago

Thanks! Looking forward to your updates.

gmlewis commented 5 years ago

It looks like @sketchbuch is solving this issue in #7 with a status bar button!

sketchbuch commented 5 years ago

My PR won't let you process all files, but I could do with this too. I could have a look at how other extensions process mutiple files. If I have time I can try and make a PR. I'm sure this must be possible, prettier can do it - that would be a good place to start. Same goes for process on save

warriorCoder commented 5 years ago

I don't think one would need to always process all files if they have stylized on save or some other such thing. However, I do think it would be good to be able to run from time to time over the whole project, especially when bringing in an unstyled project, or files.

Thank you guys for your work on this extension. :)

gmlewis commented 5 years ago

Oh, and shameless plug... please feel free to rate the plugin here: https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer

sketchbuch commented 4 years ago

I looked at this... the thing is the extension depends on methods and functions that only exist for open editors. There is no way to open a virtual editor and get access to these functions. So it would require a complete re-write of the extension, maybe as a formatting extension using the formatting API but I haven't looked deeply into it: https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices

But if you look at prettier and eslint as examples, they process files using there own methods so they can be run how they like. I'm not sure if the formatting api lets you run formatting on a files content without that content being in an open editor

gmlewis commented 4 years ago

Thank you, @sketchbuch! I appreciate the research and the report.

gmlewis commented 3 years ago

I wrote a Go stand-alone version of the flutter-stylizer that runs on Linux, Windows, and Mac which makes it easy to run on all files within a project with a single command.

It's available here: https://github.com/gmlewis/go-flutter-stylizer/

Please let me know if you have any problems with it. Closing issue as resolved.