mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.89k stars 712 forks source link

scalafmt as the formatter for Scala #3257

Open s5bug opened 4 years ago

s5bug commented 4 years ago

I'd like to start using Kakoune to get a feel for the better editing style, so I looked into the supported languages and saw that there was no formatter listed for Scala. Possibly, scalafmt could be used as the formatter and scalafix as the linter?

I don't know too much about Kakoune yet but if there's more features that other languages have to make kakoune work as an IDE then there's also Scala Metals to handle stuff.

lenormf commented 4 years ago

The editor doesn't come with default formatter/linter for the languages it can highlight. You could use something along the following, in your kakrc configuration:

hook global WinSetOption filetype=scala %{
    set-option window lintcmd "scalafix …"
}

I haven't seen any flag on scalafix that allows formatting the diagnostics in a custom format that would be interpreted by :format, you might need a shell wrapper for that.