diff --git a/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtPlugin.scala b/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtPlugin.scala index e533121..2c3d307 100644 --- a/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtPlugin.scala +++ b/sbt-scalafmt/src/main/scala/com/lucidchart/sbt/scalafmt/ScalafmtPlugin.scala @@ -2,10 +2,21 @@ package com.lucidchart.sbt.scalafmt import com.lucidchart.sbt.scalafmt.ScalafmtCorePlugin.autoImport._ import sbt._ +import sbt.Keys._ object ScalafmtPlugin extends AutoPlugin { - override val projectSettings = Seq(Compile, Test).flatMap(inConfig(_)(scalafmtSettings)) + override val projectSettings = Seq(Compile, Test).flatMap(inConfig(_)(scalafmtSettings)) ++ + inConfig(Compile)( + inTask(scalafmt)( + Seq( + sources ++= { + val finder = (baseDirectory.value * includeFilter.value) --- (baseDirectory.value * excludeFilter.value) + if (sourcesInBase.value) finder.get else Seq.empty + } + ) + ) + ) override val requires = ScalafmtCorePlugin