forked from antmicro/tlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uncrustify.cfg
140 lines (110 loc) · 7.93 KB
/
uncrustify.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Uncrustify config file for tlib
# For default settings and all possible parameters, use `uncrustify --show-config`.
# In case of some more troublesome code, formatting may be disabled using ` *INDENT-OFF` and ` *INDENT-ON*` comments.
# To use from Vim, add below lines to .vimrc:
# let g:uncrustify_cfg_file_path = 'uncrustify.cfg'
#
# function! Uncrustify(language)
# execute ':silent %!uncrustify'
# \ . ' -q '
# \ . ' -l ' . a:language
# \ . ' -c ' . g:uncrustify_cfg_file_path
# endfunction
# To use from vscode, install `LaurentTreguier.uncrustify` and add below lines to settings.json:
# "[c]": {
# "editor.defaultFormatter": "LaurentTreguier.uncrustify"
# }
# To use from kakoune, add to .kakrc
# hook global WinSetOption filetype=(c|h) %{
# set-option window formatcmd 'uncrustify -c uncrustify.cfg -l C'
# }
# All above settings assume that working directory is set to tlib top directory
newlines = LF # AUTO (default), CRLF, CR, or LF
code_width = 130 # Brakes lines longer than 150
### Spaces
sp_arith = add # space around non-assignment symbolic operators ('+', '/', '%', '<<', and so forth)
sp_arith_additive = add # space around arithmetic operators '+' and '-'. Overrides sp_arith
sp_assign = add # space around assignment operator '=', '+=', etc
sp_enum_paren = add # space in 'NS_ENUM ('
sp_enum_assign = add # space around assignment '=' in enum
sp_bool = add # space around boolean operators '&&' and '||'
sp_compare = add # space around compare operator '<', '>', '==', etc
sp_before_semi = remove # space before ';'
sp_inside_paren = remove # space inside '(' and ')'
sp_paren_paren = remove # space between nested parentheses, i.e. '((' vs. ') )'
sp_paren_brace = add # space between ')' and '{'
sp_before_ptr_star = add # space before a reference sign '&'
sp_after_ptr_star = remove # space after pointer star '*', if followed by a word
sp_between_ptr_star = remove # space between pointer stars '*'
sp_before_byref = add # space before a reference sign '&'
sp_after_byref = remove # space after a reference sign '&'
sp_before_sparen = add # space before '(' of control statements ('if', 'for', 'switch', 'while', etc.)
sp_inside_sparen = remove # space inside '(' and ')' of control statements
sp_after_sparen = add # space after ')' of control statements
sp_sparen_brace = add # space between ')' and '{' of of control statements
sp_inside_braces_empty = remove # space inside '{}'
sp_else_brace = add # space between 'else' and '{' if on the same line
sp_brace_else = add # space between '}' and 'else' if on the same line
sp_type_func = add # space between return type and function name.
sp_inside_fparen = remove # space inside function '(' and ')'
sp_inside_fparens = remove # space inside empty function '()'
sp_func_proto_paren_empty = remove # space between function name and '()' on function declaration
sp_func_call_paren = remove # space between function name and '(' on function calls
sp_after_cast = remove # space after C/D cast, i.e. 'cast(int)a' vs. 'cast(int) a' or '(int)a' vs. '(int) a'
sp_after_comma = add # space after ',', i.e. 'a,b' vs. 'a, b'.
sp_cond_colon = add # space around the ':' in 'b ? t : f'
sp_cond_question = add # space around the '?' in 'b ? t : f'
### Indent
indent_with_tabs = 0 # 0=spaces only, 1=indent to level only, 2=indent with tabs
indent_columns = 4 # spaces per indent
indent_align_string = false # whether to indent strings broken by '\' so that they line up
indent_brace = 0 # spaces to indent '{' from level
indent_braces = false # whether braces are indented to the body level
### New line
nl_max = 2 # the maximum number of consecutive newlines (3 = 2 blank lines)
nl_max_blank_in_func = 2 # the maximum number of consecutive newlines in a function
nl_if_brace = remove # newline between 'if' and '{'
nl_brace_else = remove # newline between '}' and 'else'
nl_else_brace = remove # newline between 'else' and '{'
nl_elseif_brace = remove # newline between 'else if' and '{'
nl_else_if = remove # newline between 'else' and 'if'
nl_switch_brace = remove # newline between 'switch' and '{'
nl_while_brace = remove # newline between 'while' and '{'
nl_for_brace = remove # newline between 'for' and '{'
nl_do_brace = remove # newline between 'do' and '{'
nl_enum_brace = remove # newline between 'do' and '{'
nl_union_brace = remove # newline between 'union' and '{'
nl_before_if_closing_paren = remove # newline before 'if'/'else if' closing parenthesis
nl_func_paren = remove # newline between a function name and the opening '(' in the declaration
nl_func_decl_end = remove # newline before the ')' in a function declaration
nl_func_def_end = remove # newline before the ')' in a function definition
nl_func_decl_empty = remove # newline between '()' in a function declaration
nl_func_decl_args = remove # newline after each ',' in a function declaration
nl_func_def_args = remove # newline after each ',' in a function declaration
nl_func_def_empty = remove # newline between '()' in a function definition
nl_func_call_empty = remove # newline between '()' in a function call
nl_fdef_brace = add # newline between function signature and '{'
nl_after_brace_close = false # newline after '}'. Does not apply if followed by a necessary ';'
nl_after_multiline_comment = true # newline after a multi-line comment.
nl_constr_init_args = add # newline after each ',' in the constructor member initialization.
### Code modifying
mod_full_brace_do = add # braces on single-line 'do' statement
mod_full_brace_while = add # braces on single-line 'while' statement
mod_full_brace_function = add # braces on single-line function statement
mod_full_brace_if = add # braces on single-line 'if' statement
mod_full_brace_for = add # braces on single-line 'for' statement
### Positioning - remove newlines
pos_arith = join # position of arithmetic operators in wrapped expressions
pos_bool = join # position of Boolean operators in wrapped expressions
pos_compare = join # position of comparison operators in wrapped expressions
pos_conditional = join # position of conditional operators, as in the '?' and ':' of 'expr ? stmt : stmt', in wrapped expressions
pos_assign = force # position of assign operator in wrapped expressions
pos_comma = join # position of ','in wrapped expressions
### Aligning
align_enum_equ_thresh = 0 # threshold for aligning on '+' in enums; use negative for absolute threshold
align_enum_equ_span = 4 # span for aligning on '=' in enums
align_right_cmt_span = 4 # span for aligning comments that end lines
align_pp_define_span = 4 # span for aligning preprocessor define statements
### Preprocessor macros
nl_define_macro = false # Whether to alter newlines in '#define' macros
pp_ignore_define_body = true # Whether to ignore the '#define' body while formatting