Skip to content

Brittany config indentation is not respected #543

Closed
@andys8

Description

@andys8

Subject of the issue

Formatting a project with local brittany configuration works, but the indentation is suprisingly changed. With lconfig_indentAmount: 2 one would expect 2 space indentation, but it was 4 in my case.

I changed different configuration options, to verify the file is taken into account. It is.

There is this part of the brittany formatting provider:

https://github.com/andys8/haskell-language-server/blob/91d2711f3899c3c44d48c44ede0932e961bf63ba/plugins/default/src/Ide/Plugin/Brittany.hs#L72-L84

It passes a user config with highest priority to overwrite the tab size.

{ _conf_layout =
                  mempty { _lconfig_indentAmount = opt (coerce tabSize)
                         }
              , _conf_forward =
                  (mempty :: CForwardOptions Option)
                    { _options_ghc = opt (runIdentity ( _options_ghc forwardOptionsSyntaxExtsEnabled))
                    }
              }

I think the tab size is either some default or can be influenced with defining an .editorconfig file. There was no .editorconfig before, but with adding a file like the tab size can again be set to the value defined in brittany.yaml.

[*.hs]
indent_style = space
indent_size = 2

Your environment

haskell-langauge-server 0.5.1.0
Vim 8.2 1-1704

Steps to reproduce

Tell us how to reproduce this issue.

Expected behaviour

  • Use the brittany.yaml as is
  • Or state that several configurations are in conflict

Actual behaviour

Used a different indentation.

Include debug information

Local brittany.yaml:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: formattersstatus: needs infoNot actionable, because there's missing informationtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions