Skip to content

Commit 873a8f2

Browse files
authored
Update README with configuration example
1 parent f8f3561 commit 873a8f2

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

README.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Show how lines you changed would look formatted
55

66
## Dependencies
77

8-
* POSIX compatible shell (e.g. Bash)
8+
* POSIX compatible shell (e.g. [Dash](http://gondor.apana.org.au/~herbert/dash/), [Bash](https://www.gnu.org/software/bash/))
99
* [Git](https://git-scm.com/)
1010
* [Vim](https://www.vim.org/) _(optional)_ - for config-less filetype detection
1111
* a formatter program of your choice
@@ -35,8 +35,53 @@ options:
3535

3636
1. Download [git-fmt-diff](https://raw.githubusercontent.com/Jorengarenar/git-fmt-diff/master/git-fmt-diff) file
3737
2. Set it as executable: `$ chmod +x git-fmt-diff`
38-
3. Put it into any direcory listed in `$PATH` variable
38+
3. Put it into any directory listed in `$PATH` variable
3939

4040
## Configuration
4141

42-
TODO
42+
Configuration follows the rest of Git configuration, example `~/.gitconfig`:
43+
```gitconfig
44+
# ... [user], [init] etc. ...
45+
46+
[fmt-diff]
47+
formatter-c = uncrustify -l C -c .uncrustify.cfg
48+
map-cpp = *.ipp, *.pp
49+
ignore = site-packages/*, *.sh
50+
51+
[fmt-diff "=python"]
52+
ignore = true
53+
54+
[fmt-diff "=go"]
55+
formatter = gofmt
56+
57+
[fmt-diff "tests/*"]
58+
ignore = true
59+
60+
[fmt-diff "extern/*"]
61+
ignore = true
62+
63+
[fmt-diff "extern/lib/*.c"]
64+
ignore = false
65+
formatter = astyle ...
66+
67+
[fmt-diff "extern/cpp_lib/*.h"]
68+
ignore = false
69+
filetype = cpp
70+
71+
# ... [alias], [include] etc. ...
72+
```
73+
74+
* `[fmt-diff]` - general section
75+
* `formatter-filetype` - formatter command for files with type `filetype`
76+
* `map-filetype` - comma separated list of glob patterns to map files to `filetype`
77+
* `ignore` - comma separated list of globs to ignore
78+
* `[fmt-diff "=filetype"]` - configuration for `filetype`
79+
* `formatter` - format command for this filetype
80+
* `ignore` - ignore formatting for this filetype (values: `true` or `false`)
81+
* `[fmt-diff "path/to/*/smt/*"]` - configuration for files under glob
82+
* `filetype` - map files matching glob to this filetype
83+
* `formatter` - format command for files matching this glob
84+
* `ignore` - ignore formatting for files matching glob (values: `true` or `false`)
85+
86+
Your formatter command needs to read from stdio and write to stdout.
87+
That implies command needing to be filename agnostic!

0 commit comments

Comments
 (0)