@fresh-editor/fresh-editor 0.1.87 → 0.1.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/package.json +1 -1
- package/plugins/audit_mode.ts +6 -13
- package/plugins/clangd_support.i18n.json +26 -26
- package/plugins/config-schema.json +205 -116
- package/plugins/csharp_support.i18n.json +52 -52
- package/plugins/csharp_support.ts +214 -41
- package/plugins/examples/bookmarks.ts +4 -10
- package/plugins/examples/hello_world.ts +3 -10
- package/plugins/find_references.i18n.json +91 -91
- package/plugins/git_log.i18n.json +182 -182
- package/plugins/git_log.ts +70 -165
- package/plugins/lib/finder.ts +19 -80
- package/plugins/lib/fresh.d.ts +124 -5
- package/plugins/live_grep.i18n.json +39 -39
- package/plugins/markdown_compose.i18n.json +13 -13
- package/plugins/merge_conflict.i18n.json +143 -143
- package/plugins/merge_conflict.ts +8 -20
- package/plugins/pkg.i18n.json +314 -0
- package/plugins/pkg.ts +2514 -0
- package/plugins/schemas/package.schema.json +192 -0
- package/plugins/schemas/theme.schema.json +815 -0
- package/plugins/search_replace.i18n.json +143 -143
- package/plugins/theme_editor.i18n.json +92 -14
- package/plugins/theme_editor.ts +5 -5
- package/themes/dracula.json +26 -5
- package/plugins/calculator.i18n.json +0 -93
- package/plugins/calculator.ts +0 -769
- package/plugins/color_highlighter.i18n.json +0 -145
- package/plugins/color_highlighter.ts +0 -306
- package/plugins/csharp-lsp.ts +0 -147
- package/plugins/examples/git_grep.ts +0 -262
- package/plugins/todo_highlighter.i18n.json +0 -184
- package/plugins/todo_highlighter.ts +0 -206
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cs": {
|
|
3
|
-
"cmd.enable": "Zvyraznovac barev: Povolit",
|
|
4
|
-
"cmd.enable_desc": "Povolit zvyraznovani barevnych kodu se vzorky",
|
|
5
|
-
"cmd.disable": "Zvyraznovac barev: Zakazar",
|
|
6
|
-
"cmd.disable_desc": "Zakazat zvyraznovani barevnych kodu",
|
|
7
|
-
"cmd.toggle": "Zvyraznovac barev: Prepnout",
|
|
8
|
-
"cmd.toggle_desc": "Prepnout zvyraznovani barevnych kodu",
|
|
9
|
-
"status.enabled": "Zvyraznovac barev: Povolen",
|
|
10
|
-
"status.disabled": "Zvyraznovac barev: Zakazan",
|
|
11
|
-
"status.loaded": "Plugin Zvyraznovac barev nacten"
|
|
12
|
-
},
|
|
13
|
-
"de": {
|
|
14
|
-
"cmd.enable": "Farbhervorhebung: Aktivieren",
|
|
15
|
-
"cmd.enable_desc": "Farbcode-Hervorhebung mit Farbfeldern aktivieren",
|
|
16
|
-
"cmd.disable": "Farbhervorhebung: Deaktivieren",
|
|
17
|
-
"cmd.disable_desc": "Farbcode-Hervorhebung deaktivieren",
|
|
18
|
-
"cmd.toggle": "Farbhervorhebung: Umschalten",
|
|
19
|
-
"cmd.toggle_desc": "Farbcode-Hervorhebung umschalten",
|
|
20
|
-
"status.enabled": "Farbhervorhebung: Aktiviert",
|
|
21
|
-
"status.disabled": "Farbhervorhebung: Deaktiviert",
|
|
22
|
-
"status.loaded": "Farbhervorhebung-Plugin geladen"
|
|
23
|
-
},
|
|
24
|
-
"en": {
|
|
25
|
-
"cmd.enable": "Color Highlighter: Enable",
|
|
26
|
-
"cmd.enable_desc": "Enable color code highlighting with swatches",
|
|
27
|
-
"cmd.disable": "Color Highlighter: Disable",
|
|
28
|
-
"cmd.disable_desc": "Disable color code highlighting",
|
|
29
|
-
"cmd.toggle": "Color Highlighter: Toggle",
|
|
30
|
-
"cmd.toggle_desc": "Toggle color code highlighting",
|
|
31
|
-
"status.enabled": "Color Highlighter: Enabled",
|
|
32
|
-
"status.disabled": "Color Highlighter: Disabled",
|
|
33
|
-
"status.loaded": "Color Highlighter plugin loaded"
|
|
34
|
-
},
|
|
35
|
-
"es": {
|
|
36
|
-
"cmd.enable": "Resaltador de Colores: Activar",
|
|
37
|
-
"cmd.enable_desc": "Activar resaltado de codigos de color con muestras",
|
|
38
|
-
"cmd.disable": "Resaltador de Colores: Desactivar",
|
|
39
|
-
"cmd.disable_desc": "Desactivar resaltado de codigos de color",
|
|
40
|
-
"cmd.toggle": "Resaltador de Colores: Alternar",
|
|
41
|
-
"cmd.toggle_desc": "Alternar resaltado de codigos de color",
|
|
42
|
-
"status.enabled": "Resaltador de Colores: Activado",
|
|
43
|
-
"status.disabled": "Resaltador de Colores: Desactivado",
|
|
44
|
-
"status.loaded": "Plugin Resaltador de Colores cargado"
|
|
45
|
-
},
|
|
46
|
-
"fr": {
|
|
47
|
-
"cmd.enable": "Surligneur de Couleurs: Activer",
|
|
48
|
-
"cmd.enable_desc": "Activer le surlignage des codes couleur avec apercu",
|
|
49
|
-
"cmd.disable": "Surligneur de Couleurs: Desactiver",
|
|
50
|
-
"cmd.disable_desc": "Desactiver le surlignage des codes couleur",
|
|
51
|
-
"cmd.toggle": "Surligneur de Couleurs: Basculer",
|
|
52
|
-
"cmd.toggle_desc": "Basculer le surlignage des codes couleur",
|
|
53
|
-
"status.enabled": "Surligneur de Couleurs: Active",
|
|
54
|
-
"status.disabled": "Surligneur de Couleurs: Desactive",
|
|
55
|
-
"status.loaded": "Plugin Surligneur de Couleurs charge"
|
|
56
|
-
},
|
|
57
|
-
"it": {
|
|
58
|
-
"cmd.enable": "Evidenziatore colori: Attiva",
|
|
59
|
-
"cmd.enable_desc": "Attiva l'evidenziazione dei codici colore con campioni",
|
|
60
|
-
"cmd.disable": "Evidenziatore colori: Disattiva",
|
|
61
|
-
"cmd.disable_desc": "Disattiva l'evidenziazione dei codici colore",
|
|
62
|
-
"cmd.toggle": "Evidenziatore colori: Alterna",
|
|
63
|
-
"cmd.toggle_desc": "Alterna l'evidenziazione dei codici colore",
|
|
64
|
-
"status.enabled": "Evidenziatore colori: Attivato",
|
|
65
|
-
"status.disabled": "Evidenziatore colori: Disattivato",
|
|
66
|
-
"status.loaded": "Plugin Evidenziatore colori caricato"
|
|
67
|
-
},
|
|
68
|
-
"ja": {
|
|
69
|
-
"cmd.enable": "カラーハイライター: 有効化",
|
|
70
|
-
"cmd.enable_desc": "カラーコードのハイライトとスウォッチ表示を有効化",
|
|
71
|
-
"cmd.disable": "カラーハイライター: 無効化",
|
|
72
|
-
"cmd.disable_desc": "カラーコードのハイライトを無効化",
|
|
73
|
-
"cmd.toggle": "カラーハイライター: 切り替え",
|
|
74
|
-
"cmd.toggle_desc": "カラーコードのハイライトを切り替え",
|
|
75
|
-
"status.enabled": "カラーハイライター: 有効",
|
|
76
|
-
"status.disabled": "カラーハイライター: 無効",
|
|
77
|
-
"status.loaded": "カラーハイライタープラグインを読み込みました"
|
|
78
|
-
},
|
|
79
|
-
"ko": {
|
|
80
|
-
"cmd.enable": "색상 강조기: 활성화",
|
|
81
|
-
"cmd.enable_desc": "색상 코드 강조 및 견본 표시 활성화",
|
|
82
|
-
"cmd.disable": "색상 강조기: 비활성화",
|
|
83
|
-
"cmd.disable_desc": "색상 코드 강조 비활성화",
|
|
84
|
-
"cmd.toggle": "색상 강조기: 전환",
|
|
85
|
-
"cmd.toggle_desc": "색상 코드 강조 전환",
|
|
86
|
-
"status.enabled": "색상 강조기: 활성화됨",
|
|
87
|
-
"status.disabled": "색상 강조기: 비활성화됨",
|
|
88
|
-
"status.loaded": "색상 강조기 플러그인이 로드되었습니다"
|
|
89
|
-
},
|
|
90
|
-
"pt-BR": {
|
|
91
|
-
"cmd.enable": "Destacador de Cores: Ativar",
|
|
92
|
-
"cmd.enable_desc": "Ativar destaque de codigos de cor com amostras",
|
|
93
|
-
"cmd.disable": "Destacador de Cores: Desativar",
|
|
94
|
-
"cmd.disable_desc": "Desativar destaque de codigos de cor",
|
|
95
|
-
"cmd.toggle": "Destacador de Cores: Alternar",
|
|
96
|
-
"cmd.toggle_desc": "Alternar destaque de codigos de cor",
|
|
97
|
-
"status.enabled": "Destacador de Cores: Ativado",
|
|
98
|
-
"status.disabled": "Destacador de Cores: Desativado",
|
|
99
|
-
"status.loaded": "Plugin Destacador de Cores carregado"
|
|
100
|
-
},
|
|
101
|
-
"ru": {
|
|
102
|
-
"cmd.enable": "Подсветка цветов: Включить",
|
|
103
|
-
"cmd.enable_desc": "Включить подсветку цветовых кодов с образцами",
|
|
104
|
-
"cmd.disable": "Подсветка цветов: Выключить",
|
|
105
|
-
"cmd.disable_desc": "Выключить подсветку цветовых кодов",
|
|
106
|
-
"cmd.toggle": "Подсветка цветов: Переключить",
|
|
107
|
-
"cmd.toggle_desc": "Переключить подсветку цветовых кодов",
|
|
108
|
-
"status.enabled": "Подсветка цветов: Включена",
|
|
109
|
-
"status.disabled": "Подсветка цветов: Выключена",
|
|
110
|
-
"status.loaded": "Плагин подсветки цветов загружен"
|
|
111
|
-
},
|
|
112
|
-
"th": {
|
|
113
|
-
"cmd.enable": "ตัวเน้นสี: เปิดใช้งาน",
|
|
114
|
-
"cmd.enable_desc": "เปิดใช้งานการเน้นโค้ดสีพร้อมตัวอย่างสี",
|
|
115
|
-
"cmd.disable": "ตัวเน้นสี: ปิดใช้งาน",
|
|
116
|
-
"cmd.disable_desc": "ปิดใช้งานการเน้นโค้ดสี",
|
|
117
|
-
"cmd.toggle": "ตัวเน้นสี: สลับ",
|
|
118
|
-
"cmd.toggle_desc": "สลับการเน้นโค้ดสี",
|
|
119
|
-
"status.enabled": "ตัวเน้นสี: เปิดใช้งานแล้ว",
|
|
120
|
-
"status.disabled": "ตัวเน้นสี: ปิดใช้งานแล้ว",
|
|
121
|
-
"status.loaded": "โหลดปลั๊กอินตัวเน้นสีแล้ว"
|
|
122
|
-
},
|
|
123
|
-
"uk": {
|
|
124
|
-
"cmd.enable": "Підсвічування кольорів: Увімкнути",
|
|
125
|
-
"cmd.enable_desc": "Увімкнути підсвічування кольорових кодів зі зразками",
|
|
126
|
-
"cmd.disable": "Підсвічування кольорів: Вимкнути",
|
|
127
|
-
"cmd.disable_desc": "Вимкнути підсвічування кольорових кодів",
|
|
128
|
-
"cmd.toggle": "Підсвічування кольорів: Перемкнути",
|
|
129
|
-
"cmd.toggle_desc": "Перемкнути підсвічування кольорових кодів",
|
|
130
|
-
"status.enabled": "Підсвічування кольорів: Увімкнено",
|
|
131
|
-
"status.disabled": "Підсвічування кольорів: Вимкнено",
|
|
132
|
-
"status.loaded": "Плагін підсвічування кольорів завантажено"
|
|
133
|
-
},
|
|
134
|
-
"zh-CN": {
|
|
135
|
-
"cmd.enable": "颜色高亮器: 启用",
|
|
136
|
-
"cmd.enable_desc": "启用颜色代码高亮显示和色块预览",
|
|
137
|
-
"cmd.disable": "颜色高亮器: 禁用",
|
|
138
|
-
"cmd.disable_desc": "禁用颜色代码高亮显示",
|
|
139
|
-
"cmd.toggle": "颜色高亮器: 切换",
|
|
140
|
-
"cmd.toggle_desc": "切换颜色代码高亮显示",
|
|
141
|
-
"status.enabled": "颜色高亮器: 已启用",
|
|
142
|
-
"status.disabled": "颜色高亮器: 已禁用",
|
|
143
|
-
"status.loaded": "颜色高亮器插件已加载"
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
-
|
|
3
|
-
// TypeScript Color Highlighter Plugin
|
|
4
|
-
// Highlights color codes in source code with a colored swatch
|
|
5
|
-
// Supports: #RGB, #RRGGBB, rgb(), rgba(), hsl(), hsla(), Color::Rgb()
|
|
6
|
-
const editor = getEditor();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
interface ColorHighlighterConfig {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Plugin configuration
|
|
14
|
-
const config: ColorHighlighterConfig = {
|
|
15
|
-
enabled: false, // Start disabled, use Enable or Toggle to activate
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Track which buffers need their virtual texts refreshed (content changed)
|
|
19
|
-
const dirtyBuffers = new Set<number>();
|
|
20
|
-
|
|
21
|
-
// Color block character for display
|
|
22
|
-
const COLOR_BLOCK = "█";
|
|
23
|
-
|
|
24
|
-
// Parse a hex color string to RGB
|
|
25
|
-
function parseHexColor(hex: string): [number, number, number] | null {
|
|
26
|
-
// Remove # prefix
|
|
27
|
-
hex = hex.replace(/^#/, "");
|
|
28
|
-
|
|
29
|
-
let r: number, g: number, b: number;
|
|
30
|
-
|
|
31
|
-
if (hex.length === 3) {
|
|
32
|
-
// #RGB format
|
|
33
|
-
r = parseInt(hex[0] + hex[0], 16);
|
|
34
|
-
g = parseInt(hex[1] + hex[1], 16);
|
|
35
|
-
b = parseInt(hex[2] + hex[2], 16);
|
|
36
|
-
} else if (hex.length === 6 || hex.length === 8) {
|
|
37
|
-
// #RRGGBB or #RRGGBBAA format
|
|
38
|
-
r = parseInt(hex.substring(0, 2), 16);
|
|
39
|
-
g = parseInt(hex.substring(2, 4), 16);
|
|
40
|
-
b = parseInt(hex.substring(4, 6), 16);
|
|
41
|
-
} else {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return [r, g, b];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Parse rgb() or rgba() color to RGB
|
|
53
|
-
function parseRgbColor(match: string): [number, number, number] | null {
|
|
54
|
-
const rgbMatch = match.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
55
|
-
if (!rgbMatch) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const r = parseInt(rgbMatch[1], 10);
|
|
60
|
-
const g = parseInt(rgbMatch[2], 10);
|
|
61
|
-
const b = parseInt(rgbMatch[3], 10);
|
|
62
|
-
|
|
63
|
-
if (r > 255 || g > 255 || b > 255) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return [r, g, b];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Convert HSL to RGB
|
|
71
|
-
function hslToRgb(h: number, s: number, l: number): [number, number, number] {
|
|
72
|
-
// Normalize h to 0-360, s and l to 0-1
|
|
73
|
-
h = h % 360;
|
|
74
|
-
if (h < 0) h += 360;
|
|
75
|
-
s = Math.max(0, Math.min(1, s / 100));
|
|
76
|
-
l = Math.max(0, Math.min(1, l / 100));
|
|
77
|
-
|
|
78
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
79
|
-
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
|
80
|
-
const m = l - c / 2;
|
|
81
|
-
|
|
82
|
-
let r = 0, g = 0, b = 0;
|
|
83
|
-
|
|
84
|
-
if (h >= 0 && h < 60) {
|
|
85
|
-
r = c; g = x; b = 0;
|
|
86
|
-
} else if (h >= 60 && h < 120) {
|
|
87
|
-
r = x; g = c; b = 0;
|
|
88
|
-
} else if (h >= 120 && h < 180) {
|
|
89
|
-
r = 0; g = c; b = x;
|
|
90
|
-
} else if (h >= 180 && h < 240) {
|
|
91
|
-
r = 0; g = x; b = c;
|
|
92
|
-
} else if (h >= 240 && h < 300) {
|
|
93
|
-
r = x; g = 0; b = c;
|
|
94
|
-
} else {
|
|
95
|
-
r = c; g = 0; b = x;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return [
|
|
99
|
-
Math.round((r + m) * 255),
|
|
100
|
-
Math.round((g + m) * 255),
|
|
101
|
-
Math.round((b + m) * 255),
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Parse hsl() or hsla() color to RGB
|
|
106
|
-
function parseHslColor(match: string): [number, number, number] | null {
|
|
107
|
-
const hslMatch = match.match(/hsla?\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%/);
|
|
108
|
-
if (!hslMatch) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const h = parseFloat(hslMatch[1]);
|
|
113
|
-
const s = parseFloat(hslMatch[2]);
|
|
114
|
-
const l = parseFloat(hslMatch[3]);
|
|
115
|
-
|
|
116
|
-
return hslToRgb(h, s, l);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Parse Rust Color::Rgb(r, g, b) to RGB
|
|
120
|
-
function parseRustRgbColor(match: string): [number, number, number] | null {
|
|
121
|
-
const rustMatch = match.match(/Color::Rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);
|
|
122
|
-
if (!rustMatch) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const r = parseInt(rustMatch[1], 10);
|
|
127
|
-
const g = parseInt(rustMatch[2], 10);
|
|
128
|
-
const b = parseInt(rustMatch[3], 10);
|
|
129
|
-
|
|
130
|
-
if (r > 255 || g > 255 || b > 255) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return [r, g, b];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Color patterns to match
|
|
138
|
-
const colorPatterns = [
|
|
139
|
-
{
|
|
140
|
-
// Hex colors: #RGB, #RRGGBB, #RRGGBBAA
|
|
141
|
-
regex: /#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/g,
|
|
142
|
-
parse: parseHexColor,
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
// CSS rgb() and rgba()
|
|
146
|
-
regex: /rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)/g,
|
|
147
|
-
parse: parseRgbColor,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
// CSS hsl() and hsla()
|
|
151
|
-
regex: /hsla?\s*\(\s*-?\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%\s*(?:,\s*[\d.]+\s*)?\)/g,
|
|
152
|
-
parse: parseHslColor,
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
// Rust Color::Rgb(r, g, b)
|
|
156
|
-
regex: /Color::Rgb\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/g,
|
|
157
|
-
parse: parseRustRgbColor,
|
|
158
|
-
},
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
// Process a single line for color highlighting
|
|
162
|
-
function highlightLine(
|
|
163
|
-
bufferId: number,
|
|
164
|
-
lineNumber: number,
|
|
165
|
-
byteStart: number,
|
|
166
|
-
content: string
|
|
167
|
-
): void {
|
|
168
|
-
// Search for color patterns
|
|
169
|
-
for (const pattern of colorPatterns) {
|
|
170
|
-
// Reset regex lastIndex
|
|
171
|
-
pattern.regex.lastIndex = 0;
|
|
172
|
-
|
|
173
|
-
let match;
|
|
174
|
-
while ((match = pattern.regex.exec(content)) !== null) {
|
|
175
|
-
const matchText = match[0];
|
|
176
|
-
const pos = match.index;
|
|
177
|
-
const color = pattern.parse(matchText);
|
|
178
|
-
|
|
179
|
-
if (color) {
|
|
180
|
-
const absolutePos = byteStart + pos;
|
|
181
|
-
const virtualTextId = `color-${bufferId}-${lineNumber}-${pos}`;
|
|
182
|
-
|
|
183
|
-
// Add virtual text with color swatch before the color code
|
|
184
|
-
editor.addVirtualText(
|
|
185
|
-
bufferId,
|
|
186
|
-
virtualTextId,
|
|
187
|
-
absolutePos,
|
|
188
|
-
COLOR_BLOCK + " ",
|
|
189
|
-
color[0],
|
|
190
|
-
color[1],
|
|
191
|
-
color[2],
|
|
192
|
-
true, // before the character
|
|
193
|
-
false // use_bg - use foreground color for the block character
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Clear color highlights for a buffer
|
|
201
|
-
function clearHighlights(bufferId: number): void {
|
|
202
|
-
editor.removeVirtualTextsByPrefix(bufferId, "color-");
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Handle render-start events (only clear virtual texts if buffer content changed)
|
|
206
|
-
globalThis.onColorRenderStart = function(data: { buffer_id: number }): void {
|
|
207
|
-
if (!config.enabled) return;
|
|
208
|
-
|
|
209
|
-
// Only clear and recreate virtual texts if the buffer content changed
|
|
210
|
-
if (dirtyBuffers.has(data.buffer_id)) {
|
|
211
|
-
clearHighlights(data.buffer_id);
|
|
212
|
-
dirtyBuffers.delete(data.buffer_id);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// Handle lines_changed events (batched for efficiency)
|
|
217
|
-
globalThis.onColorLinesChanged = function(data: {
|
|
218
|
-
buffer_id: number;
|
|
219
|
-
lines: Array<{
|
|
220
|
-
line_number: number;
|
|
221
|
-
byte_start: number;
|
|
222
|
-
byte_end: number;
|
|
223
|
-
content: string;
|
|
224
|
-
}>;
|
|
225
|
-
}): void {
|
|
226
|
-
if (!config.enabled) return;
|
|
227
|
-
|
|
228
|
-
// Process all changed lines
|
|
229
|
-
for (const line of data.lines) {
|
|
230
|
-
highlightLine(data.buffer_id, line.line_number, line.byte_start, line.content);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// Handle buffer content changes - mark buffer as needing virtual text refresh
|
|
235
|
-
globalThis.onColorAfterInsert = function(data: { buffer_id: number }): void {
|
|
236
|
-
dirtyBuffers.add(data.buffer_id);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
globalThis.onColorAfterDelete = function(data: { buffer_id: number }): void {
|
|
240
|
-
dirtyBuffers.add(data.buffer_id);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
// Handle buffer close events
|
|
244
|
-
globalThis.onColorBufferClosed = function(data: { buffer_id: number }): void {
|
|
245
|
-
dirtyBuffers.delete(data.buffer_id);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// Register hooks
|
|
249
|
-
editor.on("render_start", "onColorRenderStart");
|
|
250
|
-
editor.on("lines_changed", "onColorLinesChanged");
|
|
251
|
-
editor.on("after_insert", "onColorAfterInsert");
|
|
252
|
-
editor.on("after_delete", "onColorAfterDelete");
|
|
253
|
-
editor.on("buffer_closed", "onColorBufferClosed");
|
|
254
|
-
|
|
255
|
-
// Plugin commands
|
|
256
|
-
globalThis.colorHighlighterEnable = function(): void {
|
|
257
|
-
config.enabled = true;
|
|
258
|
-
// Refresh lines so next render processes all visible lines
|
|
259
|
-
const bufferId = editor.getActiveBufferId();
|
|
260
|
-
editor.refreshLines(bufferId);
|
|
261
|
-
editor.setStatus(editor.t("status.enabled"));
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
globalThis.colorHighlighterDisable = function(): void {
|
|
265
|
-
config.enabled = false;
|
|
266
|
-
const bufferId = editor.getActiveBufferId();
|
|
267
|
-
clearHighlights(bufferId);
|
|
268
|
-
editor.setStatus(editor.t("status.disabled"));
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
globalThis.colorHighlighterToggle = function(): void {
|
|
272
|
-
config.enabled = !config.enabled;
|
|
273
|
-
const bufferId = editor.getActiveBufferId();
|
|
274
|
-
if (config.enabled) {
|
|
275
|
-
// Refresh lines so next render processes all visible lines
|
|
276
|
-
editor.refreshLines(bufferId);
|
|
277
|
-
} else {
|
|
278
|
-
clearHighlights(bufferId);
|
|
279
|
-
}
|
|
280
|
-
editor.setStatus(config.enabled ? editor.t("status.enabled") : editor.t("status.disabled"));
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// Register commands
|
|
284
|
-
editor.registerCommand(
|
|
285
|
-
"%cmd.enable",
|
|
286
|
-
"%cmd.enable_desc",
|
|
287
|
-
"colorHighlighterEnable",
|
|
288
|
-
null
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
editor.registerCommand(
|
|
292
|
-
"%cmd.disable",
|
|
293
|
-
"%cmd.disable_desc",
|
|
294
|
-
"colorHighlighterDisable",
|
|
295
|
-
null
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
editor.registerCommand(
|
|
299
|
-
"%cmd.toggle",
|
|
300
|
-
"%cmd.toggle_desc",
|
|
301
|
-
"colorHighlighterToggle",
|
|
302
|
-
null
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
// Initialization
|
|
306
|
-
editor.debug("Color Highlighter initialized - supports hex, rgb, hsl, and Rust Color::Rgb");
|
package/plugins/csharp-lsp.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
-
const editor = getEditor();
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* C# LSP Helper Plugin
|
|
7
|
-
*
|
|
8
|
-
* Provides user-friendly error handling for C# LSP server issues.
|
|
9
|
-
* When csharp-ls fails to start, this plugin shows an actionable
|
|
10
|
-
* popup with installation instructions.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Detects C# LSP server errors (csharp-ls)
|
|
14
|
-
* - Shows popup with install commands (dotnet tool)
|
|
15
|
-
* - Allows copying install commands to clipboard
|
|
16
|
-
* - Provides option to disable C# LSP
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
interface LspServerErrorData {
|
|
20
|
-
language: string;
|
|
21
|
-
server_command: string;
|
|
22
|
-
error_type: string;
|
|
23
|
-
message: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface LspStatusClickedData {
|
|
27
|
-
language: string;
|
|
28
|
-
has_error: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface ActionPopupResultData {
|
|
32
|
-
popup_id: string;
|
|
33
|
-
action_id: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Install commands for C# LSP server (csharp-ls)
|
|
37
|
-
// Requires .NET SDK to be installed
|
|
38
|
-
// See: https://github.com/razzmatazz/csharp-language-server
|
|
39
|
-
const INSTALL_COMMANDS = {
|
|
40
|
-
dotnet: "dotnet tool install --global csharp-ls",
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Track error state for C# LSP
|
|
44
|
-
let csharpLspError: { serverCommand: string; message: string } | null = null;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Handle LSP server errors for C#
|
|
48
|
-
*/
|
|
49
|
-
globalThis.on_csharp_lsp_server_error = function (
|
|
50
|
-
data: LspServerErrorData
|
|
51
|
-
): void {
|
|
52
|
-
// Only handle C# language errors
|
|
53
|
-
if (data.language !== "csharp") {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
editor.debug(
|
|
58
|
-
`csharp-lsp: Server error - ${data.error_type}: ${data.message}`
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// Store error state for later reference
|
|
62
|
-
csharpLspError = {
|
|
63
|
-
serverCommand: data.server_command,
|
|
64
|
-
message: data.message,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Show a status message for immediate feedback
|
|
68
|
-
if (data.error_type === "not_found") {
|
|
69
|
-
editor.setStatus(
|
|
70
|
-
`C# LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
71
|
-
);
|
|
72
|
-
} else {
|
|
73
|
-
editor.setStatus(`C# LSP error: ${data.message}`);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Register hook for LSP server errors
|
|
78
|
-
editor.on("lsp_server_error", "on_csharp_lsp_server_error");
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Handle status bar click when there's a C# LSP error
|
|
82
|
-
*/
|
|
83
|
-
globalThis.on_csharp_lsp_status_clicked = function (
|
|
84
|
-
data: LspStatusClickedData
|
|
85
|
-
): void {
|
|
86
|
-
// Only handle C# language clicks when there's an error
|
|
87
|
-
if (data.language !== "csharp" || !csharpLspError) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
editor.debug("csharp-lsp: Status clicked, showing help popup");
|
|
92
|
-
|
|
93
|
-
// Show action popup with install options
|
|
94
|
-
editor.showActionPopup({
|
|
95
|
-
id: "csharp-lsp-help",
|
|
96
|
-
title: "C# Language Server Not Found",
|
|
97
|
-
message: `"${csharpLspError.serverCommand}" provides code completion, diagnostics, and navigation for C# files. Requires .NET SDK. Copy the command below to install it.`,
|
|
98
|
-
actions: [
|
|
99
|
-
{ id: "copy_dotnet", label: `Copy: ${INSTALL_COMMANDS.dotnet}` },
|
|
100
|
-
{ id: "disable", label: "Disable C# LSP" },
|
|
101
|
-
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
102
|
-
],
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// Register hook for status bar clicks
|
|
107
|
-
editor.on("lsp_status_clicked", "on_csharp_lsp_status_clicked");
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Handle action popup results for C# LSP help
|
|
111
|
-
*/
|
|
112
|
-
globalThis.on_csharp_lsp_action_result = function (
|
|
113
|
-
data: ActionPopupResultData
|
|
114
|
-
): void {
|
|
115
|
-
// Only handle our popup
|
|
116
|
-
if (data.popup_id !== "csharp-lsp-help") {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
editor.debug(`csharp-lsp: Action selected - ${data.action_id}`);
|
|
121
|
-
|
|
122
|
-
switch (data.action_id) {
|
|
123
|
-
case "copy_dotnet":
|
|
124
|
-
editor.setClipboard(INSTALL_COMMANDS.dotnet);
|
|
125
|
-
editor.setStatus("Copied: " + INSTALL_COMMANDS.dotnet);
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case "disable":
|
|
129
|
-
editor.disableLspForLanguage("csharp");
|
|
130
|
-
editor.setStatus("C# LSP disabled");
|
|
131
|
-
csharpLspError = null;
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case "dismiss":
|
|
135
|
-
case "dismissed":
|
|
136
|
-
// Just close the popup without action
|
|
137
|
-
break;
|
|
138
|
-
|
|
139
|
-
default:
|
|
140
|
-
editor.debug(`csharp-lsp: Unknown action: ${data.action_id}`);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// Register hook for action popup results
|
|
145
|
-
editor.on("action_popup_result", "on_csharp_lsp_action_result");
|
|
146
|
-
|
|
147
|
-
editor.debug("csharp-lsp: Plugin loaded");
|