Skip to content

Commit

Permalink
scalafmt: enable newlines.source=fold formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Apr 1, 2024
1 parent 539d461 commit 62ae842
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 212 deletions.
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ project {
newlines {
avoidForSimpleOverflow = [punct, slc, tooLong]
ignoreInSyntax = false
source = fold
}
rewrite {
rules = [
Expand Down
105 changes: 49 additions & 56 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,60 @@ def parseTagVersion: String = {
"git describe --abbrev=0 --tags".!!.drop(1).trim
}

inThisBuild(
List(
version ~= { dynVer =>
if (System.getenv("CI") != null) dynVer
else s"$parseTagVersion-SNAPSHOT" // only for local publishing
},
organization := "org.scalameta",
homepage := Some(url("https://github.com/scalameta/sbt-scalafmt")),
licenses := Seq(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
inThisBuild(List(
version ~= { dynVer =>
if (System.getenv("CI") != null) dynVer else s"$parseTagVersion-SNAPSHOT" // only for local publishing
},
organization := "org.scalameta",
homepage := Some(url("https://github.com/scalameta/sbt-scalafmt")),
licenses :=
Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"poslegm",
"Mikhail Chugunkov",
"poslegm@gmail.com",
url("https://chugunkov.website/")
),
developers := List(
Developer(
"poslegm",
"Mikhail Chugunkov",
"poslegm@gmail.com",
url("https://chugunkov.website/")
),
Developer(
"olafurpg",
"Ólafur Páll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com")
),
Developer(
"tanishiking",
"Rikito Taniguchi",
"rikiriki1238@gmail.com",
url("https://github.com/tanishiking/")
)
Developer(
"olafurpg",
"Ólafur Páll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com")
),
resolvers ++= Resolver.sonatypeOssRepos("public"),
scalaVersion := "2.12.19",
packageDoc / publishArtifact := sys.env.contains("CI"),
packageSrc / publishArtifact := sys.env.contains("CI")
)
)
Developer(
"tanishiking",
"Rikito Taniguchi",
"rikiriki1238@gmail.com",
url("https://github.com/tanishiking/")
)
),
resolvers ++= Resolver.sonatypeOssRepos("public"),
scalaVersion := "2.12.19",
packageDoc / publishArtifact := sys.env.contains("CI"),
packageSrc / publishArtifact := sys.env.contains("CI")
))
publish / skip := true

val scalafmtVersion = "3.8.1"
onLoadMessage := s"Welcome to sbt-scalafmt ${version.value} (scalafmt $scalafmtVersion)"
onLoadMessage :=
s"Welcome to sbt-scalafmt ${version.value} (scalafmt $scalafmtVersion)"

lazy val plugin = project
.enablePlugins(SbtPlugin)
.settings(
moduleName := "sbt-scalafmt",
libraryDependencies ++= List(
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"org.scalameta" %% "scalafmt-sysops" % scalafmtVersion,
"org.scalameta" %% "scalafmt-dynamic" % scalafmtVersion
),
scriptedBufferLog := false,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
// For compat reasons we have this in here to ensure we are testing against 1.2.8
// We honestly probably don't need to, so if this ever causes issues, rip it out.
pluginCrossBuild / sbtVersion := "1.2.8"
)
lazy val plugin = project.enablePlugins(SbtPlugin).settings(
moduleName := "sbt-scalafmt",
libraryDependencies ++= List(
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"org.scalameta" %% "scalafmt-sysops" % scalafmtVersion,
"org.scalameta" %% "scalafmt-dynamic" % scalafmtVersion
),
scriptedBufferLog := false,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
// For compat reasons we have this in here to ensure we are testing against 1.2.8
// We honestly probably don't need to, so if this ever causes issues, rip it out.
pluginCrossBuild / sbtVersion := "1.2.8"
)

// For some reason, it doesn't work if this is defined in globalSettings in PublishPlugin.
inScope(Global)(
Seq(
PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray())
)
)
inScope(Global)(Seq(
PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray())
))
3 changes: 1 addition & 2 deletions plugin/src/main/scala/org/scalafmt/sbt/DiffUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ object DiffUtils {
// output always has EOL; if input doesn't, pretend output has extra line
val inputNoEol = input.lastOption.forall(x => x != '\n' && x != '\r')
val b = jList(output, inputNoEol)
val patch =
generateUnifiedDiff(s"a$file", s"b$file", a, diff(a, b), 1)
val patch = generateUnifiedDiff(s"a$file", s"b$file", a, diff(a, b), 1)
if (patch.isEmpty) "" else patch.iterator().asScala.mkString("\n")
}

Expand Down
Loading

0 comments on commit 62ae842

Please sign in to comment.