29 Commits
Author SHA1 Message Date
Jen BaschandGitHub 63a20dd453 Improve org.pkl.formatter.Formatter JVM API (#1428)
Makes for less fussing around to consume this API from the Gradle side
2026-02-11 09:22:42 -08:00
Islon SchererandGitHub 08d8c8ec7a Improve import formatting (#1424) 2026-02-06 17:57:50 +01:00
32e9087da9 Fix formatting of nodes with no children (#1351)
For example, this fixes an issue where an empty module turns into ` \n`.

Closes https://github.com/apple/pkl/issues/1348

---------

Co-authored-by: Jen Basch <jbasch94@gmail.com>
2025-12-09 11:03:50 -08:00
Islon SchererandGitHub ecf2d8ba33 Fix Map formatting (#1312) 2025-11-11 09:37:09 +01:00
Islon SchererandGitHub 5030061412 Fix ordering issue in formatter (#1289) 2025-11-03 18:52:38 +01:00
Daniel ChaoandGitHub d29ae07e14 Fix formatting of argument lists (#1283)
This fixes several issues:

1. Leading/trailing line comments surrounding a lambda should make that
   lambda not "trailing", because the formatting otherwise looks bad and
   also isn't stable
2. Fix incorrect algorithm for detecting trailing lambda (currently,
   any number of lambdas makes the alg return `true`)
2025-11-03 09:15:58 -08:00
Islon SchererandGitHub 4226c21a42 Fix multiline string stability (#1287) 2025-11-03 17:41:43 +01:00
Daniel ChaoandGitHub d8adb28dd1 Respect line breaks in operator chains and argument lists (#1268)
If an operator chain or method call is multiline, keep those newlines
in the formatted output.

Help preserve code like:

```
foo
  |> (it) -> it + 2
  |> (it) -> it / 2
```
2025-11-02 21:51:37 -08:00
Islon SchererandGitHub 50541d9cda Make formatter stable (#1273) 2025-10-31 18:58:22 +01:00
ea778a7e7a Don't force multiline interpolation into a single line (#1280)
Also, fixes an issue where forced single-line formatting would break for if/else
and let expressions

---------

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-10-31 10:47:53 -07:00
Daniel ChaoandGitHub ede48d0fff Fix pkl spotless (#1279) 2025-10-30 16:17:08 -07:00
Islon SchererandGitHub db800d4521 Fix trailing lambda ending wrap (#1274) 2025-10-30 17:06:09 +01:00
Jen BaschandGitHub 08c414f3ac Normalize mutli-line string indentation (#1271) 2025-10-30 08:30:30 -07:00
Islon SchererandGitHub 9469dd885d Handle trailing commas in types (#1272) 2025-10-30 13:36:56 +01:00
Jen BaschandGitHub 7bf150055c Assert that formatter snippet test output is stable (#1270) 2025-10-29 17:08:43 -07:00
Jen BaschandGitHub 1d6261b263 Correctly handle trailing commas in function type literals in the generic parser (#1267) 2025-10-29 15:08:26 -07:00
Islon SchererandGitHub 28c20a8652 Don't break lines in module name (#1266) 2025-10-29 15:24:08 +01:00
Daniel ChaoandGitHub bbeeffdd32 Adjust formatting of line comments in lets (#1256) 2025-10-28 17:53:06 -07:00
Daniel ChaoandGitHub 825fcf5d1d Respect newlines in if/else and let expressions (#1259)
Change the formatter to prevent multiline if/else and let expressions
from collapsing into a single line.
2025-10-28 11:26:31 -07:00
Daniel ChaoandGitHub fbcf83aa76 Adjust formatting of argument lists (#1260)
This changes code so that multiple lambda arguments makes the whole
argument list wrap.

Improves the readability of code like:

```
foo
  .toMap(
    (it) -> makeSomeKey(it),
    (it) -> makeSomeValue(it)
  )
```
2025-10-28 10:46:19 -07:00
Islon SchererandGitHub be0142d46b Add grammar compatibility option to the formatter (#1249) 2025-10-28 13:29:08 +01:00
Daniel ChaoandGitHub a8f76d6209 Adjust formatting of qualified access chains (#1252)
This adjusts formatting of qualified access chains so that leading
dot calls are kept in the same line if possible.
2025-10-24 16:48:21 -07:00
Daniel ChaoandGitHub 3223083324 Format interpolated expressions as single line (#1247)
This forces iterpolated expressions to be single-line, so that newline
literals within the bounds of two string delimiters can be seen as
verbatime newlines in the resulting string.

Edge case: in the case of a line comment, it's not possible to keep
this as a single line expression.
These are kept as multi-line expressions.

Also:

* Remove `ForceWrap`, this node is not used.
* Rename `StringConstant` -> `StringChars`
2025-10-24 03:23:41 -07:00
Islon SchererandGitHub f6d3fb1228 Fix let formatting (#1246) 2025-10-21 09:45:27 +02:00
Jen BaschandGitHub 6c036bf82a Implement Pkl binary renderer and parser (#1203)
Implements a binary renderer for Pkl values, which is a lossless capturing of Pkl data.

This follows the pkl binary format that is already used with `pkl server` calls, and is
made available as a Java API and also an in-language API.

Also, introduces a binary parser into the corresponding `PObject` types in Java.
2025-10-20 09:10:22 -07:00
Daniel ChaoandGitHub 3a29ea8998 Format lambda chains (#1235)
This changes the formatter to only force line on call chains
with multiple lambdas

With this change, this is kept as a single line:

```
foo.bar.map((it) -> it + 1)
```
2025-10-09 10:16:13 -07:00
Daniel ChaoandGitHub 98ab741c54 Bump Kotlin to 2.2.20, minimum Kotlin to 2.1 (#1232)
The current version of the kotlin-gradle plugin is not compatible with
Gradle 9.1, causing error `java.lang.NoSuchMethodError:
 'org.gradle.api.Project org.gradle.api.artifacts.ProjectDependency.getDependencyProject()'`

Also, the Kotlin 2.0 language target is deprecated as of Kotlin 2.2.
2025-10-08 21:40:35 -07:00
Daniel ChaoandGitHub d03a074f63 Bump dependencies (#1225)
* byte-buddy to 1.17.7
* commonmark to 0.26

And also test dependencies (junit, assertj)
2025-10-04 13:59:54 -07:00
Islon SchererandGitHub fdc501a35c Implement canonical formatter (#1107)
CLI commands also added: `pkl format check` and `pkl format apply`.
2025-09-17 11:12:04 +02:00