scalafmt | Code formatter for Scala | Code Quality library
kandi X-RAY | scalafmt Summary
kandi X-RAY | scalafmt Summary
Head over to the user docs for instructions on how to install scalafmt.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of scalafmt
scalafmt Key Features
scalafmt Examples and Code Snippets
Community Discussions
Trending Discussions on scalafmt
QUESTION
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
:
ANSWER
Answered 2021-Aug-24 at 01:09That usage is correct.
The docs explicitly say that scalafmt
and the sbt plugin are released independently. The plugin version only covers the bits required to integrate scalafmt
with sbt: it will download the version of scalafmt
specified in .scalafmt.conf
as needed. In short, scalafmt
and the sbt plugin will almost surely not have the same version number.
QUESTION
My .scalafmt.conf
file has the following:
ANSWER
Answered 2021-Jul-11 at 01:56Since scala format defaults to specific file formats like .scala, .sbt and .sc it actually won't format .scala.html files.
This ended up being a VS code auto formatting issue for .html files.
I disabled it via:
QUESTION
I am using 'scalafmt' command to ensure that I've no formatting errors in my Scala code. It keeps failing with this error message:
...ANSWER
Answered 2020-Aug-04 at 02:40By default, Scalafmt errors are reported to System.err. Extend org.scalafmt.interfaces.ScalafmtReporter to customize error reporting to handle parse and config errors.
QUESTION
I have the scala format plugin in my multi project sbt repository.
...ANSWER
Answered 2020-Apr-06 at 13:07Scalafmt seeems to work in VSC with Metals out-of-the-box on my machine
Metals automatically uses Scalafmt to respond to formatting requests from the editor, according to the configuration defined in
.scalafmt.conf
... if there is no.scalafmt.conf
, upon receiving the first format request Metals will create the .scalafmt.conf file for you.
Simply execute Format Document
command from Command Palette
in VSC and it should format according to .scalafmt.conf.
If you would like to continuously format and compile on every source change and scalafmtOnCompile
is not working, then try executing in sbt
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install scalafmt
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page