✓ Add/remove whitespaces and commas in function calls
❏ Sort imports
❏ Enforce variable/function naming style
Enforce whitelines (in fixed number or a range):
❏ before functions
❏ on closing blocks
❏ end of file
❏ around imports
❏ Optional # to close blocks
One of the main features is to detect and correct inconsistent variable and function naming.
Using proc_naming_style = most_popular, if the same identifier appears within a file as myName more frequently and my_name and myname less frequently, nimfmt will pick the first one. This is the recommended setting to ensure consistency without having to explicitly configure nimfmt with a preferred style.
Using proc_naming_style = snake_case, if the same identifier appears as myName, my_name and myname, nimfmt will pick the second one.
Configuration
nimfmt looks for configuration files is the following order:
current directory
~/.config/nimfmt.cfg
~/.nimfmt.cfg
/etc/nimfmt.cfg
Configuration example:
# Fix inconsistent naming# auto - fix automatically# no - print warning only
fix_naming_style = "auto"# Choose the correct naming# most_popular - pick the most frequently used naming style for a given identifier# snake_case - prefer snake_case naming if possible
proc_naming_style = most_popular
Examples
Input:
procmy_foo( a: string, b:string,c:int, ):string=raisenewException ( Exception ,
"foo" )
foo ( a , b , c )
d [ a ] = 3discard"string to discard"breakreturn"string to return"
Output:
procmy_foo(a: string; b: string; c: int):string=raisenewException(Exception, "foo")
foo(a, b, c)
d[a] = 3discard"string to discard"breakreturn"string to return"
Usage
nimfmt <filename.nim> [<filename.nim> ... ]
[ -p<prefix> ] output file prefix
[ -s<suffix> ] output file suffix
[ -c<filename>, ] configuration file location(s) (default: ./.nimfmt.cfg ~/.nimfmt.cfg)
[ -i ] update files in-place (dangerous!)
[ -w ] overwrite existing files (automatically enabled when using -i)
[-v] version
[-h] this help
If any of -p ..., -s ... or -i are specified the output will be written to disk,
otherwise to stdout
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].