Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds scalafmt via spotless plugin #24

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions scala/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# tune this file as appropriate to your style! see: https://olafurpg.github.io/scalafmt/#Configuration

version = "3.7.1"

runner.dialect = "scala3"

maxColumn = 150

continuationIndent.callSite = 2

newlines {
sometimesBeforeColonInMethodReturnType = false
}

align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false

tokens = ["%", "%%"]
}

docstrings.style = Asterisk

rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}

optIn {
breaksInsideChains = true
}

project.excludeFilters = [
"metals.sbt"
]
19 changes: 18 additions & 1 deletion scala/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# 🦜️🔗 LangChain4s examples
# 🦜️🔗 LangChain4s

Build the project locally, from the project root:

```bash
./gradlew build
```

## Scalafmt

The Scala module uses the [spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle#scala) plugin.
Therefore, the previous command (`./gradlew build`) will fail in case there is any formatting issue. To apply format, you can run the following command:

```bash
./gradlew spotlessApply
```

## Examples

The following use cases show in a simplified way different functionality of LangChain4s:

Expand Down
7 changes: 7 additions & 0 deletions scala/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
plugins {
scala
alias(libs.plugins.scala.multiversion)
alias(libs.plugins.spotless)
}

repositories {
Expand Down Expand Up @@ -36,4 +37,10 @@ dependencies {

tasks.withType<Test>().configureEach {
useJUnit()
}

spotless {
scala {
scalafmt("3.7.1").configFile(".scalafmt.conf").scalaMajorVersion("2.13")
juanpedromoreno marked this conversation as resolved.
Show resolved Hide resolved
}
}