Skip to content

Commit

Permalink
Merge pull request #7 from keyhr/master
Browse files Browse the repository at this point in the history
[update] revised
  • Loading branch information
keyhr authored Jan 26, 2022
2 parents f114b28 + a591b3c commit c7cc235
Showing 1 changed file with 37 additions and 63 deletions.
100 changes: 37 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,65 @@
# c\_formatter\_42 [![Build Status](https://api.travis-ci.com/cacharle/c_formatter_42.svg?branch=master)](https://app.travis-ci.com/cacharle/c_formatter_42) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/c-formatter-42)](https://pypi.org/project/c-formatter-42/)
<h1 align="center">
c_formatter_42
</h1>

![What\_is\_it](./Img/final_back.png)
<p align="center">
<a style="text-decoration:none" href="https://badge.fury.io/py/c-formatter-42"><img src="https://badge.fury.io/py/c-formatter-42.svg" alt="PyPI version" height="20"></a>
<a style="text-decoration:none" href="https://app.travis-ci.com/cacharle/c_formatter_42"><img src="https://app.travis-ci.com/cacharle/c_formatter_42.svg?branch=master" height="20"></a>
</p>

# What is c\_formatter\_42?
<!-- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/c-formatter-42)](https://pypi.org/project/c-formatter-42/) -->

<p align="center">
<img width="65%" align="center" src="./Img/final_back.png">
</p>

## What is c_formatter_42?

It is Prettier for C in 42.
I know you are already a good Human norm.
It's just for convenience.

## Installation

## Vim

Checkout [c\_formatter\_42.vim](https://github.com/cacharle/c_formatter_42.vim)

Requires Python3.6+ (3.7, 3.8, 3.9, 3.10)

### from pypi

## VSCode

1. Install clang-format.

- MacOS
```
$ brew install clang-format
```
Or you can install vscode extension `Clang-Format`


2. Copy `.clang-format` in your Workspace directory.


3. 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,
$ pip3 install c-formatter-42
$ pip3 install --user c-formatter-42 # if you don't have root privileges
```
##### 🚨 **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!)

4. Execute code formatting
- On Windows: Shift + Alt + F
- On Mac: Shift + Option + F
- On Linux: Ctrl + Shift + I

### from source (recommended for Norminette v3 users)

#### 🚨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;
$ git clone https://github.com/cacharle/c_formatter_42
$ cd c_formatter_42
$ pip3 install -e .
```

Recommended to set in `Workspace Preference`.
## usage

---
### Vim

## Command line tool
Checkout [c_formatter_42.vim](https://github.com/cacharle/c_formatter_42.vim) plugin. This plugin automatically installs the c_formatter_42 package using pip.

### Installation
### VSCode

#### pip
1. Install [emeraldwalk.runonsave](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) extension.
2. Add Configuration to vscode. (We recommend you to put it in `Workspace Preference`)

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

#### Manual

```
$ git clone https://github.com/dawnbeen/c_formatter_42
$ cd c_formatter_42
$ pip3 install -e .
"emeraldwalk.runonsave": {
"commands": [{
"match": ".[ch]",
"cmd": "python3 -m c_formatter_42 < ${file} | tee _cfdump && cat _cfdump | tee ${file} && rm -f _cfdump"
}]
}
```
You can copy above and paste it in the `.vscode/setting.json`.

### Usage
### Command line

```
$ c_formatter_42 < file.c
Expand Down

0 comments on commit c7cc235

Please sign in to comment.