How to change tab width in scalafmt

862 Views Asked by At

I'm using VS code with metal scala extension and cannot get my code to format properly. I want to have 8 spaces tab width for everything. This is my .scalafmt.conf

version = "2.0.0-RC4"
maxColumn = 80
continuationIndent.callSite = 8
continuationIndent.defnSite = 8

Then I press Ctrl+Shift+I to format the document. Only the call sites are aligned with 8 spaces, the definition sites are aligned to 2 spaces only.

This is what my formatted code looks like.

final class Goods(
        _food: Int = 0, 
        _materials: Int = 0, 
        _products: Int = 0, 
        _fuel: Int = 0 
) {
  var raw = Array(_food, _materials, _products, _fuel)
  def food: Int = raw(0)
  def materials: Int = raw(1)
  def products: Int = raw(2)
  def fuel: Int = raw(3)
  def weight = raw.sum
}

Why isn't the body of the class aligned with 8 space?

1

There are 1 best solutions below

0
On

Because the developers of scalafmt arbitrarily don't want you to have control over your own tab width. This is the main reason I'm using scalariform instead.

https://github.com/scalameta/scalafmt/issues/1493