TheRealSyler / sass-formatter

Sass(indented syntax) formatter written in typescript
https://sass-formatter.syler.de
MIT License
10 stars 2 forks source link

Export `defaultSassFormatterConfig` or `getDefaultSassFormatterConfig` #36

Closed octref closed 3 years ago

octref commented 3 years ago

Hi @TheRealSyler, thanks a lot for your work. I see recently you added CRLF support. When I upgraded, I needed to manually add the lineEnding confing to avoid compile error.

What do you think about exposing either an object defaultSassFormatterConfig of type SassFormatterConfig, or a function getDefaultSassFormatterConfig that returns SassFormatterConfig? Currently the defaults are in the comments and not accessible through API.

Thanks again for your amazing work 👍

TheRealSyler commented 3 years ago

@octref i added a defaultSassFormatterConfig object.

you can probably just delete everything from line 44 to line 58 and replace it with

  if (this.config.vetur.format.defaultFormatter.sass === 'sass-formatter') {
      return [TextEdit.replace(range, SassFormatter.Format(document.getText(range),  {...formattingOptions, ...this.config.sass.format}))];
  }

the formatter will make sure that the options are valid i added that a while ago, now you don't need to pass all the options just the ones you want to change.

i can create a pr if you want to, let me know what you want to do.

octref commented 3 years ago

LGTM, thanks 👍