lspitzner / brittany

haskell source code formatter
GNU Affero General Public License v3.0
690 stars 72 forks source link

Indent size sometimes 4 sometimes 2 spaces #374

Closed 2dotslash closed 2 years ago

2dotslash commented 2 years ago

Apologies if this is my mistake

I'm using

lconfig_indentAmount: 4
lconfig_indentListSpecial: false

I expect indentation to only ever be 4 spaces, not to mix and match 4 and 2 spaces.

Here's a screenshot.

Screenshot from 2022-07-28 13-33-37

Lines 8-13 are indented by 10 spaces ? I expect it to be 8, and to never indent with anything other than a multiple of 4 spaces.

Here's how I expect it to be formatted.

Screenshot from 2022-07-28 13-35-49

Here's my full config, I've changed random things trying to get this to work how I expect. ~/.config/brittany/config.yaml

conf_debug:
  dconf_dump_annotations: false
  dconf_dump_ast_full: false
  dconf_dump_ast_unknown: false
  dconf_dump_bridoc_final: false
  dconf_dump_bridoc_raw: false
  dconf_dump_bridoc_simpl_alt: false
  dconf_dump_bridoc_simpl_columns: false
  dconf_dump_bridoc_simpl_floating: false
  dconf_dump_bridoc_simpl_indent: false
  dconf_dump_bridoc_simpl_par: false
  dconf_dump_config: false
  dconf_roundtrip_exactprint_only: false
conf_disable_formatting: false
conf_errorHandling:
  econf_ExactPrintFallback: ExactPrintFallbackModeInline
  econf_Werror: false
  econf_omit_output_valid_check: false
  econf_produceOutputOnErrors: false
conf_forward:
  options_ghc: []
conf_layout:
  lconfig_alignmentBreakOnMultiline: false
  lconfig_alignmentLimit: 50
  lconfig_allowHangingQuasiQuotes: false
  lconfig_allowSingleLineExportList: false
  lconfig_altChooser:
    contents: 4
    tag: AltChooserBoundedSearch
  lconfig_cols: 120
  lconfig_columnAlignMode:
    contents: 1
    tag: ColumnAlignModeMajority
  lconfig_experimentalSemicolonNewlines: false
  lconfig_hangingTypeSignature: true
  lconfig_importAsColumn: 80
  lconfig_importColumn: 80
  lconfig_indentAmount: 4
  lconfig_indentListSpecial: false
  lconfig_indentPolicy: IndentPolicyLeft
  lconfig_indentWhereSpecial: false
  lconfig_reformatModulePreamble: false
conf_obfuscate: false
conf_preprocessor:
  ppconf_CPPMode: CPPModeAbort
  ppconf_hackAroundIncludes: false
conf_roundtrip_exactprint_only: false
conf_version: 1
2dotslash commented 2 years ago

Closing this because really what annoyed me was the whitespace error plugin I'm using, I turned it off for haskell files and moved on with my life.

What I did realise is line 8 in my screenshot is indented 4 spaces relative to the "P" in Project, not the start of the line. This probably has all sorts of reasons why and all I seen was my beautiful rainbow indentation being destroyed.

Thank you

AleXoundOS commented 2 years ago

@2dotslash, what is the "whitespace plugin" and how to turn it off?

AleXoundOS commented 2 years ago

Also, is it possible to force 2 spaces?

2dotslash commented 2 years ago

@AleXoundOS

I'm using indent-rainbow in vscode

https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow

It has a feature to highlight where whitespace was not indented correctly, I disabled it for haskell and markdown in my vscode settings.json with the following line

"indentRainbow.ignoreErrorLanguages": ["haskell", "markdown"]

Here's the colours I'm using for indent-rainbow if you're interested, also set in vscode settings.json

"indentRainbow.colors": [
        "rgba(123, 248, 197,0.08)",
        "rgba(130, 209, 204,0.08)",
        "rgba(136, 170, 211,0.08)",
        "rgba(143, 132, 218,0.08)",
        "rgba(150, 93, 225,0.08)",
        "rgba(162, 84, 219,0.08)",
        "rgba(177, 89, 206,0.08)",
        "rgba(191, 94, 194,0.08)",
        "rgba(206, 99, 181,0.08)",
        "rgba(210, 111, 169,0.08)",
        "rgba(193, 137, 157,0.08)",
        "rgba(175, 162, 146,0.08)",
        "rgba(158, 188, 134,0.08)",
        "rgba(140, 213, 122,0.08)"
    ],

Also, is it possible to force 2 spaces?

Just realised what you're asking, the indent-rainbow plugin uses your vscode indent settings I think, so yes it will work for you.

I use 4 spaces for everything else it's just my preference.