-
Notifications
You must be signed in to change notification settings - Fork 388
/
extensions.ts
35 lines (34 loc) · 1010 Bytes
/
extensions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {closeBrackets} from '@codemirror/autocomplete'
import {defaultKeymap, history, historyKeymap} from '@codemirror/commands'
import {javascriptLanguage} from '@codemirror/lang-javascript'
import {
bracketMatching,
defaultHighlightStyle,
indentOnInput,
syntaxHighlighting,
} from '@codemirror/language'
import {highlightSelectionMatches} from '@codemirror/search'
import {type Extension} from '@codemirror/state'
import {
drawSelection,
highlightActiveLine,
highlightActiveLineGutter,
highlightSpecialChars,
keymap,
lineNumbers,
} from '@codemirror/view'
export const codemirrorExtensions: Extension[] = [
[javascriptLanguage],
lineNumbers(),
highlightActiveLine(),
highlightActiveLineGutter(),
highlightSelectionMatches(),
highlightSpecialChars(),
indentOnInput(),
bracketMatching(),
closeBrackets(),
history(),
drawSelection(),
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
keymap.of([defaultKeymap, historyKeymap].flat().filter(Boolean)),
]