| 1 |
import { HighlightStyle } from "@codemirror/language"; |
| 2 |
import { tags } from "@lezer/highlight"; |
| 3 |
|
| 4 |
export const beancountEditorHighlight = HighlightStyle.define([ |
| 5 |
{ |
| 6 |
// Dates |
| 7 |
tag: tags.special(tags.number), |
| 8 |
color: "var(--editor-date)", |
| 9 |
}, |
| 10 |
{ |
| 11 |
// Accounts |
| 12 |
tag: tags.className, |
| 13 |
color: "var(--editor-account)", |
| 14 |
}, |
| 15 |
{ |
| 16 |
// Plain comments |
| 17 |
tag: tags.comment, |
| 18 |
color: "var(--editor-comment)", |
| 19 |
}, |
| 20 |
{ |
| 21 |
// Sections |
| 22 |
tag: tags.special(tags.lineComment), |
| 23 |
color: "var(--editor-comment)", |
| 24 |
border: "solid 1px var(--editor-comment)", |
| 25 |
borderRadius: "2px", |
| 26 |
paddingRight: "10px", |
| 27 |
fontWeight: "500", |
| 28 |
}, |
| 29 |
{ |
| 30 |
// Currencies |
| 31 |
tag: tags.unit, |
| 32 |
color: "var(--editor-currencies)", |
| 33 |
}, |
| 34 |
{ |
| 35 |
// Directives |
| 36 |
tag: tags.keyword, |
| 37 |
fontWeight: "500", |
| 38 |
color: "var(--editor-directive)", |
| 39 |
}, |
| 40 |
{ |
| 41 |
// Option name |
| 42 |
tag: tags.standard(tags.string), |
| 43 |
color: "var(--editor-class)", |
| 44 |
}, |
| 45 |
{ |
| 46 |
// Tag, link |
| 47 |
tag: tags.labelName, |
| 48 |
color: "var(--editor-label-name)", |
| 49 |
}, |
| 50 |
{ |
| 51 |
// Currency value |
| 52 |
tag: tags.number, |
| 53 |
color: "var(--editor-number)", |
| 54 |
}, |
| 55 |
{ |
| 56 |
// Payee, Narration |
| 57 |
tag: tags.string, |
| 58 |
color: "var(--editor-string)", |
| 59 |
}, |
| 60 |
{ |
| 61 |
// Invalid token |
| 62 |
tag: tags.invalid, |
| 63 |
color: "var(--editor-invalid)", |
| 64 |
backgroundColor: "var(--editor-invalid-background)", |
| 65 |
}, |
| 66 |
]); |
| 67 |
|
| 68 |
export const beancountQueryHighlight = HighlightStyle.define([ |
| 69 |
{ |
| 70 |
// Keywords: Select, Where, And |
| 71 |
tag: tags.keyword, |
| 72 |
color: "var(--bql-keywords)", |
| 73 |
}, |
| 74 |
{ |
| 75 |
// Values |
| 76 |
tag: [ |
| 77 |
tags.typeName, |
| 78 |
tags.className, |
| 79 |
tags.number, |
| 80 |
tags.changed, |
| 81 |
tags.annotation, |
| 82 |
tags.modifier, |
| 83 |
tags.self, |
| 84 |
tags.namespace, |
| 85 |
], |
| 86 |
color: "var(--bql-values)", |
| 87 |
}, |
| 88 |
{ |
| 89 |
// Strings |
| 90 |
tag: [tags.processingInstruction, tags.string, tags.inserted], |
| 91 |
color: "var(--bql-string)", |
| 92 |
}, |
| 93 |
{ |
| 94 |
// Errors |
| 95 |
tag: [ |
| 96 |
tags.name, |
| 97 |
tags.deleted, |
| 98 |
tags.character, |
| 99 |
tags.propertyName, |
| 100 |
tags.macroName, |
| 101 |
], |
| 102 |
color: "var(--bql-errors)", |
| 103 |
}, |
| 104 |
]); |