cue/format: expose indent option

Change-Id: Ib66be75914726c62982af78d7f3c32ff3cdf1594
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9481
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/format/format.go b/cue/format/format.go
index b3c3c69..5e81eb3 100644
--- a/cue/format/format.go
+++ b/cue/format/format.go
@@ -57,6 +57,12 @@
 	return func(c *config) { c.TabIndent = indent }
 }
 
+// IndentPrefix specifies the number of tabstops to use as a prefix for every
+// line.
+func IndentPrefix(n int) Option {
+	return func(c *config) { c.Indent = n }
+}
+
 // TODO: make public
 // sortImportsOption causes import declarations to be sorted.
 func sortImportsOption() Option {
diff --git a/cue/format/printer.go b/cue/format/printer.go
index b39e016..a43154f 100644
--- a/cue/format/printer.go
+++ b/cue/format/printer.go
@@ -124,7 +124,7 @@
 			// 2) simplified structs are explicitly referenced separately
 			//    in the AST.
 			if p.indent < 6 {
-				data = literal.IndentTabs(data, p.indent+1)
+				data = literal.IndentTabs(data, p.cfg.Indent+p.indent+1)
 			}
 
 		case token.INT: