csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Request for support of custom file extensions to scan/fix

Open NovaVoidHowl opened this issue 1 year ago • 1 comments

Request

As it currently stands, it is not possible to scan C# files that have custom extensions (for build/deployment processes etc.) The only work around for this, is to have a special script/process: that changes the extension, runs CSharpier, then puts the extension back.

Concept

Add a config section to the '.csharpierrc.*' that allows the user to pick the file extensions to target ie.

printWidth: 120
useTabs: false
tabWidth: 2
fileExtensions:
  - .cs
  - .cs.custom

NovaVoidHowl avatar Apr 07 '24 18:04 NovaVoidHowl

I have a PR with partly implemented csproj formatting and had the same idea because it made sense to allow someone to use that formatter for xml, props, etc. I'll work on getting the ability to specify formatters for other extensions it into the next release.

One possibility

formatters:
  - type: csharp
    extensions: [ ".cs", ".cs.custom" ]
  - type: xml
    extensions: [ ".xml", ".csproj" ]

Or maybe support it with .editorconfig.

[*.{cs,cs.custom}]
csharpier_formatter = csharp

[*.xml]
csharpier_formatter = xml

I should also take a look at how prettier does this.

belav avatar Apr 18 '24 16:04 belav