formatter: new approach for indentation that doesn't depend on original formatting (#2764)

This commit is contained in:
Tyler Wilding
2023-06-21 23:16:18 -05:00
committed by GitHub
parent f980c733b2
commit 533d2f6f2b
13 changed files with 427 additions and 405 deletions
@@ -15,14 +15,14 @@ Comment - Within Form
===
(println
;; test
"test")
;; test
"test")
---
(println
;; test
"test")
;; test
"test")
===
@@ -117,8 +117,8 @@ Block Comment - In Form
---
(println
#|
#|
block comment
test
|#
"test")
"test")
@@ -10,42 +10,71 @@ One Pair
(:hello "world")
===
Three Pairs
===
(:hello
"world" :world 123
:test 456)
---
(:hello "world" :world 123 :test 456)
===
Four Pairs
===
(:hello
"world" :world 123
:test 456
:doit 789)
---
(:hello "world"
:world 123
:test 456
:doit 789)
===
Not a Valid Constant
===
(:hello
(println "hello world"))
---
(:hello
(println "hello world"))
===
Two Pairs
===
(:hello
"world" :test 123)
"world" :world 123
:test 456
:not (println "hello world")
:doit 789)
---
(:hello "world"
:test 123)
:world 123
:test 456
:not
(println "hello world")
:doit 789)
===
Pair Mixture
Amibiguous List
===
(:hello
"world" "not-a-pair" :test 123)
"world" :world 123
:test 456
:not-paired
:doit 789)
---
(:hello "world"
"not-a-pair"
:test 123)
:world 123
:test 456
:not-paired
:doit 789)
@@ -1,64 +0,0 @@
===
All Alignment
===
(println "hello" (println "world" "world2"))
---
(println "hello"
(println "world"
"world2"))
===
Multiple Top Level Forms
===
(println "hello" "world")(println "hello" "world")
---
(println "hello"
"world")
(println "hello"
"world")
===
All Indented
===
(println
"hello" (println
"world"))
---
(println
"hello"
(println
"world"))
===
Mixed
===
(println
"hello" (println "world"))
---
(println
"hello"
(println "world"))
===
Single Item Form
===
(println)
---
(println)
@@ -0,0 +1,60 @@
===
Basic Nested Form
===
(println "hello" (println "world" "world2" "very-long-formvery-long-formvery-long-formvery-long-formvery-long-formvery-long-formvery-long-form"))
---
(println
"hello"
(println
"world"
"world2"
"very-long-formvery-long-formvery-long-formvery-long-formvery-long-formvery-long-formvery-long-form"))
===
Multiple Top Level Forms
===
(println "hello" "world")(println "hello" "world")
---
(println "hello" "world")
(println "hello" "world")
===
All Indented
===
(println
"hello" (println
"world"))
---
(println "hello" (println "world"))
===
Mixed
===
(println
"hello" (println "world"))
---
(println "hello" (println "world"))
===
Single Item Form
===
(println)
---
(println)
@@ -1,19 +0,0 @@
===
Basic Inner Indentation
===
(defun greet (name string)
(println "Hello" name)
(println "Hello" name)
(println "Hello" name)
)
---
(defun greet (name string)
(println "Hello"
name)
(println "Hello"
name)
(println "Hello"
name))