|
| 1 | +import { tags as t } from '@lezer/highlight'; |
| 2 | +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; |
| 3 | + |
| 4 | +export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'] = { |
| 5 | + background: '#002b36', |
| 6 | + foreground: '#93a1a1', |
| 7 | + caret: '#839496', |
| 8 | + selection: '#173541', |
| 9 | + selectionMatch: '#aafe661a', |
| 10 | + gutterBackground: '#00252f', |
| 11 | + gutterForeground: '#839496', |
| 12 | + lineHighlight: '#173541', |
| 13 | +}; |
| 14 | + |
| 15 | +export const solarizedDarkInit = (options?: Partial<CreateThemeOptions>) => { |
| 16 | + const { theme = 'dark', settings = {}, styles = [] } = options || {}; |
| 17 | + return createTheme({ |
| 18 | + theme: theme, |
| 19 | + settings: { |
| 20 | + ...defaultSettingsSolarizedDark, |
| 21 | + ...settings, |
| 22 | + }, |
| 23 | + styles: [ |
| 24 | + { tag: t.keyword, color: '#859900' }, |
| 25 | + { |
| 26 | + tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], |
| 27 | + color: '#2aa198', |
| 28 | + }, |
| 29 | + { tag: [t.variableName], color: '#93a1a1' }, |
| 30 | + { tag: [t.function(t.variableName)], color: '#268bd2' }, |
| 31 | + { tag: [t.labelName], color: '#d33682' }, |
| 32 | + { |
| 33 | + tag: [t.color, t.constant(t.name), t.standard(t.name)], |
| 34 | + color: '#b58900', |
| 35 | + }, |
| 36 | + { tag: [t.definition(t.name), t.separator], color: '#2aa198' }, |
| 37 | + { tag: [t.brace], color: '#d33682' }, |
| 38 | + { |
| 39 | + tag: [t.annotation], |
| 40 | + color: '#d30102', |
| 41 | + }, |
| 42 | + { |
| 43 | + tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], |
| 44 | + color: '#d33682', |
| 45 | + }, |
| 46 | + { |
| 47 | + tag: [t.typeName, t.className], |
| 48 | + color: '#cb4b16', |
| 49 | + }, |
| 50 | + { |
| 51 | + tag: [t.operator, t.operatorKeyword], |
| 52 | + color: '#6c71c4', |
| 53 | + }, |
| 54 | + { |
| 55 | + tag: [t.tagName], |
| 56 | + color: '#268bd2', |
| 57 | + }, |
| 58 | + { |
| 59 | + tag: [t.squareBracket], |
| 60 | + color: '#dc322f', |
| 61 | + }, |
| 62 | + { |
| 63 | + tag: [t.angleBracket], |
| 64 | + color: '#586e75', |
| 65 | + }, |
| 66 | + { |
| 67 | + tag: [t.attributeName], |
| 68 | + color: '#93a1a1', |
| 69 | + }, |
| 70 | + { |
| 71 | + tag: [t.regexp], |
| 72 | + color: '#d30102', |
| 73 | + }, |
| 74 | + { |
| 75 | + tag: [t.quote], |
| 76 | + color: '#859900', |
| 77 | + }, |
| 78 | + { tag: [t.string], color: '#b58900' }, |
| 79 | + { |
| 80 | + tag: t.link, |
| 81 | + color: '#2aa198', |
| 82 | + textDecoration: 'underline', |
| 83 | + textUnderlinePosition: 'under', |
| 84 | + }, |
| 85 | + { |
| 86 | + tag: [t.url, t.escape, t.special(t.string)], |
| 87 | + color: '#b58900', |
| 88 | + }, |
| 89 | + { tag: [t.meta], color: '#dc322f' }, |
| 90 | + { tag: [t.comment], color: '#586e75', fontStyle: 'italic' }, |
| 91 | + { tag: t.strong, fontWeight: 'bold', color: '#eee8d5' }, |
| 92 | + { tag: t.emphasis, fontStyle: 'italic', color: '#859900' }, |
| 93 | + { tag: t.strikethrough, textDecoration: 'line-through' }, |
| 94 | + { tag: t.heading, fontWeight: 'bold', color: '#b58900' }, |
| 95 | + { tag: t.heading1, fontWeight: 'bold', color: '#fdf6e3' }, |
| 96 | + { |
| 97 | + tag: [t.heading2, t.heading3, t.heading4], |
| 98 | + fontWeight: 'bold', |
| 99 | + color: '#eee8d5', |
| 100 | + }, |
| 101 | + { |
| 102 | + tag: [t.heading5, t.heading6], |
| 103 | + color: '#eee8d5', |
| 104 | + }, |
| 105 | + { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' }, |
| 106 | + { |
| 107 | + tag: [t.processingInstruction, t.inserted, t.contentSeparator], |
| 108 | + color: '#dc322f', |
| 109 | + }, |
| 110 | + { |
| 111 | + tag: [t.contentSeparator], |
| 112 | + color: '#b58900', |
| 113 | + }, |
| 114 | + { tag: t.invalid, color: '#586e75', borderBottom: `1px dotted #dc322f` }, |
| 115 | + ...styles, |
| 116 | + ], |
| 117 | + }); |
| 118 | +}; |
| 119 | + |
| 120 | +export const solarizedDark = solarizedDarkInit(); |
0 commit comments