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 /** ktfmt breaks lines longer than maxWidth. */ 21 val maxWidth: Int = DEFAULT_MAX_WIDTH, 22 23 /** 24 * blockIndent is the size of the indent used when a new block is opened, in spaces. 25 * 26 * For example, 27 * ``` 28 * fun f() { 29 * // 30 * } 31 * ``` 32 */ 33 val blockIndent: Int, 34 35 /** 36 * continuationIndent is the size of the indent used when a line is broken because it's too 37 * long, in spaces. 38 * 39 * For example, 40 * ``` 41 * val foo = bar( 42 * 1) 43 * ``` 44 */ 45 val continuationIndent: Int, 46 47 /** 48 * Automatically remove and insert trialing commas. 49 * 50 * Lists that cannot fit on one line will have trailing commas inserted. Lists that span 51 * multiple lines will have them removed. Manually inserted trailing commas cannot be used as a 52 * hint to force breaking lists to multiple lines. 53 */ 54 val manageTrailingCommas: Boolean = true, 55 56 /** Whether ktfmt should remove imports that are not used. */ 57 val removeUnusedImports: Boolean = true, 58 59 /** 60 * Print the Ops generated by KotlinInputAstVisitor to help reason about formatting (i.e., 61 * newline) decisions 62 */ 63 val debuggingPrintOpsAfterFormatting: Boolean = false, 64 ) { 65 companion object { 66 const val DEFAULT_MAX_WIDTH: Int = 100 67 } 68 } 69