# GTK coding style # # https://gitlab.gnome.org/GNOME/gtk/-/blob/main/docs/CODING-STYLE.md # # Configuration based on: # - https://github.com/uncrustify/uncrustify/blob/master/etc/gnu-indent.cfg # - https://gitlab.gnome.org/GNOME/mutter/-/blob/main/tools/uncrustify.cfg # - https://gitlba.gnome.org/GNOME/nautilus/-/blob/main/data/uncrustify.cfg # # Run `uncrustify --show-config` to see documentation for these options. utf8_force = true newlines = lf input_tab_size = 8 output_tab_size = 8 indent_columns = 2 indent_with_tabs = 0 # Spaces only indent_brace = 2 indent_ternary_operator = 1 # When the `if_false` is a continuation, indent it under `if_false` indent_switch_case = 2 indent_switch_body = 2 indent_case_brace = 0 nl_after_semicolon = true nl_start_of_file = remove nl_end_of_file = force nl_end_of_file_min = 1 nl_func_decl_args = force nl_func_def_args = force nl_func_decl_end = remove nl_func_type_name = force nl_func_decl_args = force nl_func_def_args = force nl_func_decl_end = remove nl_func_call_end = remove nl_func_call_empty = remove nl_func_var_def_blk = 1 # Newlines for other statements (if, switch,..) 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_elseif_brace = add nl_while_brace = add nl_switch_brace = add nl_squeeze_ifdef = true nl_fcall_brace = force nl_fdef_brace = force nl_brace_else = force nl_assign_brace = remove nl_brace_while = remove nl_case_colon_brace = remove nl_after_brace_open = true nl_before_case = 1 sp_arith = force # foo = 1 + (2 / 4); sp_arith_additive = force sp_bool = force sp_compare = force # (foo > 1) sp_assign = force # foo = 2; sp_after_assign = force sp_before_assign = force sp_after_comma = force sp_after_cast = ignore sp_not = ignore # if (!foo) sp_after_byref = remove # & for indirections must be together with the variable sp_before_semi = remove sp_incdec = remove # (i++) sp_inside_braces = force # { 1 } sp_inside_braces_struct = force # { 1 } sp_inside_braces_enum = force # { 1 } sp_inside_paren = remove sp_inside_fparen = remove sp_inside_sparen = remove sp_inside_for = remove sp_between_ptr_star = remove # char **foo; sp_before_ptr_star_func = force sp_after_ptr_star = remove sp_after_ptr_star_func = force sp_ptr_star_paren = force # typedef GNode* (* ForeachFunc) (...); # class Foo:public sp_before_class_colon = remove sp_after_class_colon = add sp_inside_paren = remove # "( 1 )" vs "(1)" sp_inside_fparen = remove # "( 1 )" vs "(1)" - functions sp_inside_sparen = remove # "( 1 )" vs "(1)" - if/for/etc sp_before_sparen = force # "if (" vs "if(" - if/for/etc sp_paren_paren = remove # ((foo)) # Enforce the right spacing inside/around/after ( ) in typedefs and # function calls sp_inside_tparen = remove sp_after_tparen_close = force sp_func_call_paren = force sp_func_def_paren = force sp_func_proto_paren = force sp_func_proto_paren_empty = force # Remove space between glib/gettext i18n function shortcuts and ( set func_call_user _ C_ I_ N_ NC_ P_ Q_ sp_func_call_user_paren = remove # We align parameters in function definitions, like this: # # int64_t meta_string_to_date (const char *date_string, # int *offset_p, # GError **error) # align_func_params = true # A '*' in a variable definition is considered 'dangling', rather than # being part of the variable type. This produces the following style of # alignment: # # meta_string_to_date (const gchar *date_string, # gint *offset_p, # GError **error) # align_var_def_star_style = 2 # int foo_bar (const int a) # MyType *bar_foo (const int b) align_func_proto_span = 4 # Disable auto-alignment of macros, we often manually align the \ with # spaces which uncrustify doesn't support. align_nl_cont = false # Add stars at the beginning of each line in multiline comments cmt_star_cont = true # Ignore spacing in multiline comments. cmt_indent_multi = false # Code modifications # Enforce the use of braces for do, for, while and function blocks mod_full_brace_do = force mod_full_brace_function = force mod_full_brace_while = force mod_full_brace_for = remove mod_full_brace_if = remove # Add braces to all blocks if any block needs braces and remove braces if they can be removed from all blocks mod_full_brace_if_chain = 1 # Remove braces on single-line 'using ()' statement mod_full_brace_using = remove # Prevent removal of braces from 'if'/'for'/'while'/etc. blocks which span multiple lines. mod_full_brace_nl_block_rem_mlcond = true # Remove blanks eat_blanks_before_close_brace = true eat_blanks_after_open_brace = true