|
| 1 | +import { EditorView } from 'codemirror'; |
| 2 | +import { javaLanguage } from '@codemirror/lang-java'; |
| 3 | +import { HighlightStyle, LanguageSupport, syntaxHighlighting } from '@codemirror/language'; |
| 4 | +import { styleTags, tags } from '@lezer/highlight'; |
| 5 | + |
| 6 | +const snippetJava = javaLanguage.configure({ props: [styleTags({ |
| 7 | + 'Annotation/Identifier MarkerAnnotation/Identifier': tags.annotation, |
| 8 | + 'ClassDeclaration/Definition InterfaceDeclaration/Definition EnumDeclaration/Definition': tags.typeName, |
| 9 | + 'MethodDeclaration/Definition ConstructorDeclaration/Definition': tags.function(tags.variableName), |
| 10 | + 'ImportDeclaration/ScopedIdentifier!': tags.namespace |
| 11 | +})] }); |
| 12 | + |
| 13 | +export const editorJava = new LanguageSupport(snippetJava); |
| 14 | + |
| 15 | +export const editorTheme = [ |
| 16 | + EditorView.theme({ |
| 17 | + '&': { color: '#e6edf7', backgroundColor: 'transparent' }, |
| 18 | + '.cm-content': { caretColor: '#e6edf7', padding: '1rem 0' }, |
| 19 | + '.cm-line': { padding: '0 1.15rem' }, |
| 20 | + '.cm-gutters': { color: '#7f90ad', backgroundColor: 'transparent', border: 'none' }, |
| 21 | + '.cm-activeLine, .cm-activeLineGutter': { backgroundColor: '#ffffff08' }, |
| 22 | + '&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection': { backgroundColor: '#334e6880' }, |
| 23 | + '.cm-cursor, .cm-dropCursor': { borderLeftColor: '#e6edf7' }, |
| 24 | + '.cm-tooltip, .cm-panels': { color: '#e6edf7', backgroundColor: '#172033', borderColor: '#334e68' }, |
| 25 | + '.cm-searchMatch': { backgroundColor: '#b39b5e55' }, |
| 26 | + '.cm-searchMatch-selected': { backgroundColor: '#b39b5e88' }, |
| 27 | + '.cm-matchingBracket': { backgroundColor: '#7dd3fc26', outline: '1px solid #7dd3fc66' } |
| 28 | + }, { dark: true }), |
| 29 | + syntaxHighlighting(HighlightStyle.define([ |
| 30 | + { tag: tags.name, color: '#dce6f2' }, |
| 31 | + { tag: tags.comment, color: '#7f90ad', fontStyle: 'italic' }, |
| 32 | + { tag: [tags.keyword, tags.bool], color: '#ffb86c' }, |
| 33 | + { tag: [tags.typeName, tags.annotation, tags.function(tags.variableName)], color: '#7dd3fc' }, |
| 34 | + { tag: tags.string, color: '#a7f3c1' }, |
| 35 | + { tag: tags.number, color: '#f6c177' }, |
| 36 | + { tag: [tags.namespace, tags.attributeName], color: '#c4b5fd' }, |
| 37 | + { tag: [tags.operator, tags.punctuation], color: '#c9d4e5' }, |
| 38 | + { tag: tags.invalid, color: '#ffd6d6', backgroundColor: '#b43e4747' } |
| 39 | + ])) |
| 40 | +]; |
0 commit comments