Skip to content

Instantly share code, notes, and snippets.

@jlnquere
Created December 11, 2012 09:59
Show Gist options
  • Save jlnquere/4257436 to your computer and use it in GitHub Desktop.
Save jlnquere/4257436 to your computer and use it in GitHub Desktop.
Configuration de base pour Uncrustify dans un environement objective-c ou objective-c++.
#
# Configuration de base pour Uncrustify dans un environement objective-c ou
# objective-c++.
#
# Plus d'informations ici: http://wp.me/p2VLPv-Js
#
# Travail basé sur https://gist.github.com/261662/ et
# https://github.com/octo-online/Xcode-formatter/blob/master/CodeFormatter/uncrustify_objective_c.cfg
#
# Julien Quéré - http://webd.fr
indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs
output_tab_size = 4 # new tab size
indent_columns = output_tab_size
indent_label = output_tab_size # pos: absolute col, neg: relative column
indent_align_assign = true
indent_align_string = true
#
# Indenting
#
indent_brace = 0
indent_switch_case = indent_columns
#
# Inter-symbol newlines
#
nl_enum_brace = remove # "enum {" vs "enum \n {"
nl_union_brace = remove # "union {" vs "union \n {"
nl_struct_brace = remove # "struct {" vs "struct \n {"
nl_do_brace = remove # "do {" vs "do \n {"
nl_if_brace = remove # "if () {" vs "if () \n {"
nl_for_brace = remove # "for () {" vs "for () \n {"
nl_else_brace = remove # "else {" vs "else \n {"
nl_while_brace = remove # "while () {" vs "while () \n {"
nl_switch_brace = remove # "switch () {" vs "switch () \n {"
nl_brace_while = add # "} while" vs "} \n while" - cuddle while
nl_brace_else = remove # "} else" vs "} \n else" - cuddle else
nl_func_var_def_blk = 1
nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{"
nl_fdef_brace = add # "int foo() {" vs "int foo()\n{"
nl_after_return = true
nl_before_case = true
nl_after_case = true
# Whether to collapse empty blocks between '{' and '}'
nl_collapse_empty_body = true # false/true
nl_start_of_file = remove
nl_end_of_file = add
nl_end_of_file_min = 1
nl_comment_func_def = 1
nl_else_if = remove
nl_elseif_brace = remove
# Add or remove newline before 'if'
nl_before_if = add # ignore/add/remove/force
# Add or remove newline after 'if'
nl_after_if = add # ignore/add/remove/force
# Add or remove newline before 'while'
nl_before_while = add # ignore/add/remove/force
# Add or remove newline after 'while'
nl_after_while = add # ignore/add/remove/force
# Add or remove newline before 'for'
nl_before_for = add # ignore/add/remove/force
# Add or remove newline after 'for'
nl_after_for = add # ignore/add/remove/force
# Whether to alter newlines in '#define' macros
nl_define_macro = true # false/true
# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif'
nl_squeeze_ifdef = true # false/true
#
# Source code modifications
#
mod_paren_on_return = remove # "return 1;" vs "return (1);"
mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }"
mod_full_brace_for = add # "for () a--;" vs "for () { a--; }"
mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();"
mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }"
mod_add_long_ifdef_endif_comment = 20
mod_add_long_ifdef_else_comment = mod_add_long_ifdef_else_comment
mod_add_long_switch_closebrace_comment = mod_add_long_ifdef_else_comment
mod_add_long_function_closebrace_comment = mod_add_long_ifdef_else_comment
# Add parens on 'while' and 'if' statement around bools
mod_full_paren_if_bool = true # false/true
# Whether to remove superfluous semicolons
mod_remove_extra_semicolon = true # false/true
# If TRUE, it will remove a void 'return;' that appears as the last statement in a function.
mod_remove_empty_return = true # false/true
#
# Inter-character spacing options
#
sp_return_paren = force # "return (1);" vs "return(1);"
sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)"
sp_before_sparen = force # "if (" vs "if("
sp_after_sparen = force # "if () {" vs "if (){"
sp_after_cast = remove # "(int) a" vs "(int)a"
sp_inside_braces = force # "{ 1 }" vs "{1}"
sp_inside_braces_struct = force # "{ 1 }" vs "{1}"
sp_inside_braces_enum = force # "{ 1 }" vs "{1}"
# Add or remove space inside empty function '()'
sp_inside_fparens = remove # ignore/add/remove/force
# Add or remove space inside function '(' and ')'
sp_inside_fparen = remove # ignore/add/remove/force
# Add or remove space between ']' and '(' when part of a function call.
sp_square_fparen = remove # ignore/add/remove/force
# Add or remove space between ')' and '{' of function
sp_fparen_brace = add # ignore/add/remove/force
sp_inside_paren = remove
sp_paren_brace = force
sp_paren_paren = remove
sp_balance_nested_parens = false
sp_assign = force
sp_arith = force
sp_bool = force
sp_compare = force
sp_assign = force
sp_after_comma = force
sp_func_def_paren = remove # "int foo (){" vs "int foo(){"
sp_func_call_paren = remove # "foo (" vs "foo("
sp_func_proto_paren = remove # "int foo ();" vs "int foo();"
sp_before_ptr_star = force
sp_after_ptr_star = remove
sp_before_unnamed_ptr_star = force
sp_between_ptr_star = remove
sp_after_ptr_star_func = remove
sp_before_ptr_star_func = force
sp_cmt_cpp_start = ignore
sp_cond_question = force
sp_cond_colon = force
sp_else_brace = force
sp_brace_else = force
# Add or remove space between '}' and the name of a typedef on the same line
sp_brace_typedef = force # ignore/add/remove/force
sp_after_class_colon = force
sp_before_class_colon = force
sp_before_case_colon = remove
sp_after_invariant_paren = force
# Objective-C specifics
# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'
sp_after_oc_scope = add # ignore/add/remove/force
# Add or remove space after the colon in message specs
# '-(int) f:(int) x;' vs '-(int) f: (int) x;'
sp_after_oc_colon = remove # ignore/add/remove/force
# Add or remove space before the colon in message specs
# '-(int) f: (int) x;' vs '-(int) f : (int) x;'
sp_before_oc_colon = remove # ignore/add/remove/force
# Add or remove space after the colon in message specs
# '[object setValue:1];' vs '[object setValue: 1];'
sp_after_send_oc_colon = remove # ignore/add/remove/force
# Add or remove space before the colon in message specs
# '[object setValue:1];' vs '[object setValue :1];'
sp_before_send_oc_colon = remove # ignore/add/remove/force
# Add or remove space after the (type) in message specs
# '-(int)f: (int) x;' vs '-(int)f: (int)x;'
sp_after_oc_type = remove # ignore/add/remove/force
# Add or remove space after the first (type) in message specs
# '-(int) f:(int)x;' vs '-(int)f:(int)x;'
sp_after_oc_return_type = remove # ignore/add/remove/force
# Add or remove space between '@selector' and '('
# '@selector(msgName)' vs '@selector (msgName)'
# Also applies to @protocol() constructs
sp_after_oc_at_sel = remove # ignore/add/remove/force
# Add or remove space between '@selector(x)' and the following word
# '@selector(foo) a:' vs '@selector(foo)a:'
sp_after_oc_at_sel_parens = add # ignore/add/remove/force
# Add or remove space inside '@selector' parens
# '@selector(foo)' vs '@selector( foo )'
# Also applies to @protocol() constructs
sp_inside_oc_at_sel_parens = remove # ignore/add/remove/force
# Add or remove space before a block pointer caret
# '^int (int arg){...}' vs. ' ^int (int arg){...}'
sp_before_oc_block_caret = remove # ignore/add/remove/force
# Add or remove space after a block pointer caret
# '^int (int arg){...}' vs. '^ int (int arg){...}'
sp_after_oc_block_caret = remove # ignore/add/remove/force
#
# Aligning stuff
#
align_with_tabs = false # use tabs to align
align_on_tabstop = false # align on tabstops
align_number_left = false # Whether to left-align numbers: false/true
# Align variable definitions in prototypes and functions
align_func_params = true # false/true
align_keep_tabs = true # Whether to keep non-indenting tabs: false / true
align_enum_equ_span = 1 # '=' in enum definition
align_nl_cont = true
align_var_def_span = 1
align_var_def_inline = false
align_var_def_colon = true
align_assign_span = 1
align_struct_init_span = 2 # align stuff in a structure init '= { }'
align_pp_define_span = 3
align_pp_define_gap = 4
align_oc_msg_colon_span = 1 # align parameters in an Obj-C message on the ':' but stop after this many lines (0=don't align)
align_oc_msg_spec_span = 0 # the span for aligning ObjC msg spec (0=don't align)
align_oc_decl_colon = true
# How to align the star in variable definitions.
# 0=Part of the type 'void * foo;'
# 1=Part of the variable 'void *foo;'
# 2=Dangling 'void *foo;'
align_var_def_star_style = 2 # number
# The span for aligning comments that end lines (0=don't align)
align_right_cmt_span = 3 # number
# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment
align_right_cmt_mix = false # false/true
# If a trailing comment is more than this number of columns away from the text it follows,
# it will qualify for being aligned.
align_right_cmt_gap = 0 # number
# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore)
align_right_cmt_at_col = 1 # number
# Whether to align macros wrapped with a backslash and a newline.
# This will not work right if the macro contains a multi-line comment.
align_nl_cont = true # false/true
# The minimum space between label and value of a preprocessor define
align_pp_define_gap = 4 # number
# The span for aligning on '#define' bodies (0=don't align)
align_pp_define_span = 3 # number
#
# Line Splitting options
#
# Try to limit code width to N number of columns
code_width = 140 # number
# Whether to fully split long 'for' statements at semi-colons
ls_for_split_full = false # false/true
# Whether to fully split long function protos/calls at commas
ls_func_split_full = true # false/true
#
# Blank line options
#
# The maximum consecutive newlines
nl_max = 2 # number
# The number of newlines after a function prototype, if followed by another function prototype
nl_after_func_proto = 0 # number
# The number of newlines after a function prototype, if not followed by another function prototype
nl_after_func_proto_group = 2 # number
# The number of newlines after '}' of a multi-line function body
nl_after_func_body = 2 # number
# The number of newlines after '}' of a single line function body
nl_after_func_body_one_liner = 2 # number
# The minimum number of newlines before a multi-line comment.
# Doesn't apply if after a brace open or another multi-line comment.
nl_before_block_comment = 2 # number
# The minimum number of newlines before a single-line C comment.
# Doesn't apply if after a brace open or other single-line C comments.
nl_before_c_comment = 1 # number
# The minimum number of newlines before a CPP comment.
# Doesn't apply if after a brace open or other CPP comments.
nl_before_cpp_comment = 1 # number
# Whether to force a newline after a mulit-line comment.
nl_after_multiline_comment = false # false/true
# The number of newlines between a function def and the function comment.
# 0 = No change.
nl_comment_func_def = 1 # number
# The number of newlines after a try-catch-finally block that isn't followed by a brace close.
# 0 = No change.
nl_after_try_catch_finally = 2 # number
# Whether to put a newline after a brace close.
# Does not apply if followed by a necessary ';'.
nl_after_brace_close = false # false/true
# Whether to remove blank lines after '{'
eat_blanks_after_open_brace = true # false/true
# Whether to remove blank lines before '}'
eat_blanks_before_close_brace = true # false/true
# Control indent of preprocessors inside #if blocks at brace level 0
pp_indent = add # ignore/add/remove/force
# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false)
pp_indent_at_level = false # false/true
# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1.
pp_indent_count = 2 # number
# Add or remove space after # based on pp_level of #if blocks
pp_space = remove # ignore/add/remove/force
# Sets the number of spaces added with pp_space
pp_space_count = 0 # number
# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level
pp_indent_if = 1 # number
# Control whether to indent the code between #if, #else and #endif when not at file-level
pp_if_indent_code = true # false/true
# Whether to indent '#define' at the brace level (true) or from column 1 (false)
pp_define_at_level = false # false/true
#
# Comment modifications
#
# Try to wrap comments at cmt_width columns
cmt_width = 0 # number
# If false, disable all multi-line comment changes, including cmt_width and leading chars.
# Default is true.
cmt_indent_multi = true # false/true
# Whether to group c-comments that look like they are in a block
cmt_c_group = true # false/true
# Whether to change cpp-comments into c-comments
cmt_cpp_to_c = false # false/true
# Whether to group c-comments that look like they are in a block
cmt_c_group = true # false/true
# Whether to group cpp-comments that look like they are in a block
cmt_cpp_group = true # false/true
# Whether to put an empty '/*' on the first line of the combined c-comment
cmt_c_nl_start = false # false/true
# Whether to put a newline before the closing '*/' of the combined c-comment
cmt_c_nl_end = true # false/true
# Whether to group cpp-comments that look like they are in a block
cmt_cpp_group = false # false/true
# Whether to put a star on subsequent comment lines
cmt_star_cont = true # false/true
# The number of spaces to insert at the start of subsequent comment lines
cmt_sp_before_star_cont = 0 # number
# The number of spaces to insert after the star on subsequent comment lines
cmt_sp_after_star_cont = 2 # number
# Set the comment reflow mode (default: 0)
# 0: no reflowing (apart from the line wrapping due to cmt_width)
# 1: no touching at all
# 2: full reflow
cmt_reflow_mode = 2 # number
cmt_multi_check_last = true
cmt_insert_file_header = "/usr/local/etc/uncrustify/standard-comment-header.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment