Skip to content

Commit ce27e98

Browse files
authored
Update README.md
1 parent 44c70c2 commit ce27e98

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,58 @@
1-
# atom-ide-code-format
1+
# Code Format
2+
3+
Format a selection of code using the `code-format:format-code` command.
4+
(Also accessible via context menu, or "Edit > Text > Format Code").
5+
6+
When no selection is provided, the entire file is formatted.
7+
8+
![Code Format](./images/code-format.gif)
9+
10+
Code Format also provides APIs to:
11+
12+
- format code as you type
13+
- format code on save (after you press save but before writing to disk).
14+
15+
You can enable format-on-save using plain range/file providers from the
16+
"atom-ide-code-format" section in the `atom-ide-ui` package settings.
17+
18+
## Service API
19+
20+
Provide code format [Atom services](http://flight-manual.atom.io/behind-atom/sections/interacting-with-other-packages-via-services/) by adding one or more of these to your `package.json`:
21+
(Only the ones that you want to use; you don't need all of them!)
22+
23+
```
24+
"providedServices": {
25+
"code-format.range": {
26+
"versions": {
27+
"0.1.0": "provideRangeCodeFormat"
28+
}
29+
},
30+
"code-format.file": {
31+
"versions": {
32+
"0.1.0": "provideFileCodeFormat"
33+
}
34+
},
35+
"code-format.onType": {
36+
"versions": {
37+
"0.1.0": "provideOnTypeCodeFormat"
38+
}
39+
},
40+
"code-format.onSave": {
41+
"versions": {
42+
"0.1.0": "provideOnSaveCodeFormat"
43+
}
44+
}
45+
}
46+
```
47+
48+
Then, in your package entry point:
49+
50+
```
51+
export function provideRangeCodeFormat(): RangeCodeFormatProvider {}
52+
export function provideFileCodeFormat(): FileCodeFormatProvider {}
53+
export function provideOnTypeCodeFormat(): OnTypeCodeFormatProvider {}
54+
export function provideOnSaveCodeFormat(): OnSaveCodeFormatProvider {}
55+
```
56+
57+
The various provider types are described in
58+
[`atom-ide-code-format/lib/types.js`](../modules/atom-ide-ui/pkg/atom-ide-code-format/lib/types.js).

0 commit comments

Comments
 (0)