formatting tool complient with 42 school's norm
Project description
Intro
It is Prettier of C for 42. I know you are already a good Human norm. It's just for convenience.
Vim
Checkout c_formatter_42.vim
VSCode
- Install clang-format.
- MacOS
$ brew install clang-format
Or you can install vscode extension Clang-Format
-
Copy
.clang-format
in your Workspace directory. -
VSCode Settings
- Set Default Formatter as clang-format.
- Turn off
Format On Paste
,Format On Save
. - Or You can just copy this in your
.vscode/settings.json
file.
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
🚨 CAUTION Check your clang-format version.
If version is lower than 10, SpaceBeforeSquareBrackets: false
and AllowShortBlocksOnASingleLine: Never
can't work well.
So you should comment them out!)
- Execute code formatting
- On Windows: Shift + Alt + F
- On Mac: Shift + Option + F
- On Linux: Ctrl + Shift + I
🚨Caution(VSCode)
It's not perfect. You should format these rules MANUALLY after auto-formatting.
global aligned
declarations aligned
declarations must be followed by one empty line
Empty line
int aaaa = 12;
float b = 23;
std::string ccc = 23;
Recommended to set in Workspace Preference
.
Command line tool
Installation
pip
$ pip3 install c-formatter-42
Manual
$ git clone https://github.com/dawnbeen/c_formatter_42
$ cd c_formatter_42
$ pip3 install -e .
Usage
$ c_formatter_42 < file.c
$ python3 -m c_formatter_42 < file.c # If you get 'command not found' with the previous one
$ c_formatter_42 --help
usage: c_formatter_42 [-h] [-c] [FILE [FILE ...]]
Format C source according to the norm
positional arguments:
FILE File to format inplace, if no file is provided read STDIN
optional arguments:
-h, --help show this help message and exit
-c, --confirm Ask confirmation before overwritting any file
Feel free to report issues or contribute. :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
c_formatter_42-0.0.2.tar.gz
(9.9 kB
view hashes)
Built Distribution
Close
Hashes for c_formatter_42-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d67983fcc666841ad4479384c21db5e0cd97ee96a16815ba0996bb54bc004eaa |
|
MD5 | b5820499ffb1e1e6358094e68d0d0c2f |
|
BLAKE2b-256 | 0a8dfdd245e9b503ad367e64d373c0fc403a9365f8a6494c8f45ce0579863d36 |