I like the clean code, I mean code formatted with for example scalafmt (https://scalameta.org/scalafmt/).
I've always add the file .scalafmt.conf in the root folder of the project. Then, everytime I save a source file it gets formatted accordingly.
As far as I know I can also add a plugin in the plugins.sbt file. With this, there are new sbt tasks for checking if sources are formatted, format sources, etc.
Q1 Is this the right way to use it (adding the .scalafmt.conf file and adding the plugin)?
Q2 Version in the plugin must be the same as version in .scalafmt.conf? Example:
.scalafmt.conf:
version = 2.6.4
...
plugins.sbt:
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
...
That usage is correct.
The docs explicitly say that
scalafmtand the sbt plugin are released independently. The plugin version only covers the bits required to integratescalafmtwith sbt: it will download the version ofscalafmtspecified in.scalafmt.confas needed. In short,scalafmtand the sbt plugin will almost surely not have the same version number.