Skip to content

cacharle/c_formatter_42

 
 

Repository files navigation

PyPI version


c_formatter_42

C language prettier that conforms to 42 norm v3. I know you are already a good human norm. It's just for convenience.

Installation

Requires Python3.7+ (3.8, 3.9, 3.10, 3.11)

From PyPI

$ pip3 install c-formatter-42
$ pip3 install --user c-formatter-42  # If you don't have root privileges

From source

$ git clone https://github.com/cacharle/c_formatter_42
$ cd c_formatter_42
$ pip3 install -e .

Usage

Command line

$ 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 overwriting any file

Plugins / Extensions

Vim

Check out the c_formatter_42.vim plugin. This plugin automatically installs the c_formatter_42 package using pip.

Visual Studio Code

  1. Install c_formatter_42
  2. Install the keyhr.42-c-format extension
  3. Set keyhr.42-c-format as the default formatter for C files in .vscode/settings.json
{
  "[c]": {
    "editor.defaultFormatter": "keyhr.42-c-format"
  }
}

Contributing

Feel free to report issues or contribute. :)