• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.facebook.ktfmt.format
18 
19 data class FormattingOptions(
20     val style: Style = Style.FACEBOOK,
21 
22     /** ktfmt breaks lines longer than maxWidth. */
23     val maxWidth: Int = DEFAULT_MAX_WIDTH,
24 
25     /**
26      * blockIndent is the size of the indent used when a new block is opened, in spaces.
27      *
28      * For example,
29      * ```
30      * fun f() {
31      *   //
32      * }
33      * ```
34      */
35     val blockIndent: Int = 2,
36 
37     /**
38      * continuationIndent is the size of the indent used when a line is broken because it's too
39      * long, in spaces.
40      *
41      * For example,
42      * ```
43      * val foo = bar(
44      *     1)
45      * ```
46      */
47     val continuationIndent: Int = 4,
48 
49     /** Whether ktfmt should remove imports that are not used. */
50     val removeUnusedImports: Boolean = true,
51 
52     /**
53      * Print the Ops generated by KotlinInputAstVisitor to help reason about formatting (i.e.,
54      * newline) decisions
55      */
56     val debuggingPrintOpsAfterFormatting: Boolean = false
57 ) {
58 
59   companion object {
60     const val DEFAULT_MAX_WIDTH: Int = 100
61   }
62 
63   enum class Style {
64     FACEBOOK,
65     DROPBOX,
66     GOOGLE
67   }
68 }
69