Skip to content

Commit 032c8e3

Browse files
committed
Add a usage section to readme
1 parent be72c42 commit 032c8e3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,28 @@ We aim to be an inclusive, welcoming community. To make that explicit,
1616
we have a [code of
1717
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
1818
to communication around the project.
19+
20+
## Usage
21+
22+
```javascript
23+
import {EditorView} from "@codemirror/view"
24+
import {autocompletion} from "@codemirror/autocomplete"
25+
import {jsonLanguage} from "@codemirror/lang-json"
26+
27+
const view = new EditorView({
28+
parent: document.body,
29+
extensions: [
30+
jsonLanguage,
31+
autocompletion(),
32+
jsonLanguage.data.of({
33+
autocomplete: ["id", "name", "address"]
34+
})
35+
]
36+
})
37+
```
38+
39+
This configuration will just complete the given words anywhere in JSON
40+
context. Most language modules come with more refined autocompletion
41+
built-in, but you can also write your own custom autocompletion
42+
[sources](https://codemirror.net/docs/ref/#autocomplete.CompletionSource)
43+
and associate them with your language this way.

0 commit comments

Comments
 (0)