1

I am using vs code for my scala/play application.

Whenever I save my main.scala.html layout file, the formatting screws up my references to my assets files.

It inserts a space and my references to my css and js files fails.

<link rel="stylesheet" media="screen" href="@routes.Assets.versioned(" dist/styles.min.css")"> <link

Note: there is a space between (" dist/...")

If I remove the space and save, it gets inserted again.

I first thought it was scala format, but if I explicitly exclude the file it doesnt' do anything.

In my .scalafmt.conf file I added: (I added the project.excludeFilters setting):

version = "2.4.0"
align = more
maxColumn = 110
spaces.inImportCurlyBraces = true
rewrite.rules = [SortImports, RedundantParens, SortModifiers]
rewrite.redundantBraces.stringInterpolation = true
project.excludeFilters = [
  "myapp/app/views/main.scala.html"
]

I am using scala format version 2.4.0

I'm not sure if this is scala format or metals doing this?

My extensions are:

enter image description here

Blankman
  • 259,732
  • 324
  • 769
  • 1,199
  • Check VS Code extensions, maybe you have https://marketplace.visualstudio.com/items?itemName=lonefy.vscode-JS-CSS-HTML-formatter or some other HTML formatter. Scalafmt would not be able to format HTML files. This looks like HTML formatter which doesn't know Scala syntax and thinks that inner `"` is an end of attribute value. – Mateusz Kubuszok Jun 12 '20 at 07:14
  • @MateuszKubuszok these are my extensions...(uploaded an image) – Blankman Jun 12 '20 at 14:05

1 Answers1

0

It is the editor formatter that tries to space out attributes. Quick workaround is to use single quotes for the attributes.

<link rel="stylesheet" media="screen" href='@routes.Assets.versioned(" dist/styles.min.css")'> <link>

As mentioned in https://stackoverflow.com/a/71148190/155689

Or disable HTML formatting all together as https://stackoverflow.com/a/68332727/155689 with

"html.format.enable": false,
flurdy
  • 3,782
  • 29
  • 31