【问题标题】:How to configure Uncrustify for Allman style for Swift iOS programming?如何为 Swift iOS 编程配置 Allman 风格的 Uncrustify?
【发布时间】:2016-03-27 19:55:34
【问题描述】:

我正在尝试为 UncrustifyX 获取一个配置,该配置将使用 Allman Style 与 Swift 一起使用。我在 Xcode 中使用 BBUncrustifyPlugin。到目前为止,这是我所拥有的:

# indent using tabs
input_tab_size                           = 8
output_tab_size                          = 4
indent_columns                           = output_tab_size
indent_with_tabs                         = 1

# indent case
indent_switch_case                       = indent_columns
indent_case_brace                        = 0

# indent class body
indent_class                             = True

# newlines
nl_after_semicolon                       = true

# spaces
# add in general
sp_before_sparen                         = add
# but remove for
sp_version_paren                         = remove
sp_catch_paren                           = remove
sp_scope_paren                           = remove
sp_func_call_user_paren                  = remove

# Allman style for curly braces
nl_assign_brace                          = add
nl_enum_brace                            = add
nl_union_brace                           = add
nl_struct_brace                          = add
nl_class_brace                           = add
nl_do_brace                              = add
nl_if_brace                              = add
nl_for_brace                             = add
nl_else_brace                            = add
nl_while_brace                           = add
nl_switch_brace                          = add
nl_fcall_brace                           = add
nl_fdef_brace                            = add
nl_brace_else                            = add
nl_brace_while                           = remove
nl_case_colon_brace                      = add
nl_after_brace_open                      = true

# one liners
nl_func_leave_one_liners                 = true
nl_enum_leave_one_liners                 = true
nl_create_if_one_liner                   = true
nl_create_for_one_liner                  = true
nl_create_while_one_liner                = true

它使大部分大括号正确,但将感叹号和问号分开,并有一些其他问题。我不确定我还能做些什么来让它正常工作。

我做了一个要点here

【问题讨论】:

  • 您好,您有没有找到更好的配置或对此进行了改进?我正在为我们的团队寻找好的 swift-code formater 并找到了您的问题
  • 还没有,我很感兴趣,如果你发现了什么,请告诉我。我还在用上面的。
  • 也许swiftcleanapp.com 是一个选项,因为我没有得到与 Swift 一致的工作。

标签: ios swift uncrustify


【解决方案1】:

首先我要说:我不能帮你配置uncrustify。

但也许我可以为您提供另一个解决方案:您应该看看开源命令行工具swiftformat。其中还有supports the allman- aka east-coast- style

https://github.com/nicklockwood/SwiftFormat

【讨论】:

    猜你喜欢
    • 2015-12-22
    • 1970-01-01
    • 2012-01-18
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    相关资源
    最近更新 更多