aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/client.ts2
-rw-r--r--editors/code/src/color_theme.ts28
-rw-r--r--editors/code/src/commands/analyzer_status.ts2
-rw-r--r--editors/code/src/commands/expand_macro.ts2
-rw-r--r--editors/code/src/commands/index.ts4
-rw-r--r--editors/code/src/commands/syntax_tree.ts2
-rw-r--r--editors/code/src/ctx.ts14
-rw-r--r--editors/code/src/highlighting.ts12
-rw-r--r--editors/code/src/inlay_hints.ts4
-rw-r--r--editors/code/src/source_change.ts2
-rw-r--r--editors/code/src/status_display.ts2
11 files changed, 37 insertions, 37 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 94948b10f..743384bd7 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -79,7 +79,7 @@ export function createClient(config: Config): lc.LanguageClient {
79 } 79 }
80 }, 80 },
81 }; 81 };
82 res.registerProposedFeatures() 82 res.registerProposedFeatures();
83 return res; 83 return res;
84} 84}
85function expandPathResolving(path: string) { 85function expandPathResolving(path: string) {
diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts
index 1df7eba7a..cbad47f35 100644
--- a/editors/code/src/color_theme.ts
+++ b/editors/code/src/color_theme.ts
@@ -32,29 +32,29 @@ export class ColorTheme {
32 ? [rule.scope] 32 ? [rule.scope]
33 : rule.scope; 33 : rule.scope;
34 for (const scope of scopes) { 34 for (const scope of scopes) {
35 res.rules.set(scope, rule.settings) 35 res.rules.set(scope, rule.settings);
36 } 36 }
37 } 37 }
38 return res 38 return res;
39 } 39 }
40 40
41 lookup(scopes: string[]): TextMateRuleSettings { 41 lookup(scopes: string[]): TextMateRuleSettings {
42 let res: TextMateRuleSettings = {} 42 let res: TextMateRuleSettings = {};
43 for (const scope of scopes) { 43 for (const scope of scopes) {
44 this.rules.forEach((value, key) => { 44 this.rules.forEach((value, key) => {
45 if (scope.startsWith(key)) { 45 if (scope.startsWith(key)) {
46 res = mergeRuleSettings(res, value) 46 res = mergeRuleSettings(res, value);
47 } 47 }
48 }) 48 });
49 } 49 }
50 return res 50 return res;
51 } 51 }
52 52
53 mergeFrom(other: ColorTheme) { 53 mergeFrom(other: ColorTheme) {
54 other.rules.forEach((value, key) => { 54 other.rules.forEach((value, key) => {
55 const merged = mergeRuleSettings(this.rules.get(key), value) 55 const merged = mergeRuleSettings(this.rules.get(key), value);
56 this.rules.set(key, merged) 56 this.rules.set(key, merged);
57 }) 57 });
58 } 58 }
59} 59}
60 60
@@ -73,15 +73,15 @@ function loadThemeNamed(themeName: string): ColorTheme {
73 return ext.packageJSON.contributes.themes 73 return ext.packageJSON.contributes.themes
74 .filter((it: any) => (it.id || it.label) === themeName) 74 .filter((it: any) => (it.id || it.label) === themeName)
75 .map((it: any) => path.join(ext.extensionPath, it.path)); 75 .map((it: any) => path.join(ext.extensionPath, it.path));
76 }) 76 });
77 77
78 const res = new ColorTheme(); 78 const res = new ColorTheme();
79 for (const themePath of themePaths) { 79 for (const themePath of themePaths) {
80 res.mergeFrom(loadThemeFile(themePath)) 80 res.mergeFrom(loadThemeFile(themePath));
81 } 81 }
82 82
83 const customizations: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations'); 83 const customizations: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations');
84 res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? [])) 84 res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? []));
85 85
86 return res; 86 return res;
87} 87}
@@ -89,7 +89,7 @@ function loadThemeNamed(themeName: string): ColorTheme {
89function loadThemeFile(themePath: string): ColorTheme { 89function loadThemeFile(themePath: string): ColorTheme {
90 let text; 90 let text;
91 try { 91 try {
92 text = fs.readFileSync(themePath, 'utf8') 92 text = fs.readFileSync(themePath, 'utf8');
93 } catch { 93 } catch {
94 return new ColorTheme(); 94 return new ColorTheme();
95 } 95 }
@@ -119,5 +119,5 @@ function mergeRuleSettings(
119 foreground: override.foreground ?? defaultSetting?.foreground, 119 foreground: override.foreground ?? defaultSetting?.foreground,
120 background: override.background ?? defaultSetting?.background, 120 background: override.background ?? defaultSetting?.background,
121 fontStyle: override.fontStyle ?? defaultSetting?.fontStyle, 121 fontStyle: override.fontStyle ?? defaultSetting?.fontStyle,
122 } 122 };
123} 123}
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index cf37dc6f0..cfe7d1af0 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -49,7 +49,7 @@ class TextDocumentContentProvider
49 _uri: vscode.Uri, 49 _uri: vscode.Uri,
50 ): vscode.ProviderResult<string> { 50 ): vscode.ProviderResult<string> {
51 const editor = vscode.window.activeTextEditor; 51 const editor = vscode.window.activeTextEditor;
52 const client = this.ctx.client 52 const client = this.ctx.client;
53 if (!editor || !client) return ''; 53 if (!editor || !client) return '';
54 54
55 return client.sendRequest<string>( 55 return client.sendRequest<string>(
diff --git a/editors/code/src/commands/expand_macro.ts b/editors/code/src/commands/expand_macro.ts
index 472f43b8d..dcdde78af 100644
--- a/editors/code/src/commands/expand_macro.ts
+++ b/editors/code/src/commands/expand_macro.ts
@@ -52,7 +52,7 @@ class TextDocumentContentProvider
52 52
53 async provideTextDocumentContent(_uri: vscode.Uri): Promise<string> { 53 async provideTextDocumentContent(_uri: vscode.Uri): Promise<string> {
54 const editor = vscode.window.activeTextEditor; 54 const editor = vscode.window.activeTextEditor;
55 const client = this.ctx.client 55 const client = this.ctx.client;
56 if (!editor || !client) return ''; 56 if (!editor || !client) return '';
57 57
58 const position = editor.selection.active; 58 const position = editor.selection.active;
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index 4431fdcf6..9a1697dcb 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -36,14 +36,14 @@ function showReferences(ctx: Ctx): Cmd {
36function applySourceChange(ctx: Ctx): Cmd { 36function applySourceChange(ctx: Ctx): Cmd {
37 return async (change: sourceChange.SourceChange) => { 37 return async (change: sourceChange.SourceChange) => {
38 sourceChange.applySourceChange(ctx, change); 38 sourceChange.applySourceChange(ctx, change);
39 } 39 };
40} 40}
41 41
42function reload(ctx: Ctx): Cmd { 42function reload(ctx: Ctx): Cmd {
43 return async () => { 43 return async () => {
44 vscode.window.showInformationMessage('Reloading rust-analyzer...'); 44 vscode.window.showInformationMessage('Reloading rust-analyzer...');
45 await ctx.restartServer(); 45 await ctx.restartServer();
46 } 46 };
47} 47}
48 48
49export { 49export {
diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts
index 2ee80f910..02ea9f166 100644
--- a/editors/code/src/commands/syntax_tree.ts
+++ b/editors/code/src/commands/syntax_tree.ts
@@ -76,7 +76,7 @@ class TextDocumentContentProvider
76 76
77 provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> { 77 provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> {
78 const editor = vscode.window.activeTextEditor; 78 const editor = vscode.window.activeTextEditor;
79 const client = this.ctx.client 79 const client = this.ctx.client;
80 if (!editor || !client) return ''; 80 if (!editor || !client) return '';
81 81
82 let range: lc.Range | undefined; 82 let range: lc.Range | undefined;
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 13988056a..a2a4e42a9 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,7 +1,7 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import { Config } from './config'; 3import { Config } from './config';
4import { createClient } from './client' 4import { createClient } from './client';
5 5
6export class Ctx { 6export class Ctx {
7 readonly config: Config; 7 readonly config: Config;
@@ -10,28 +10,28 @@ export class Ctx {
10 // deal with it. 10 // deal with it.
11 // 11 //
12 // Ideally, this should be replaced with async getter though. 12 // Ideally, this should be replaced with async getter though.
13 client: lc.LanguageClient | null = null 13 client: lc.LanguageClient | null = null;
14 private extCtx: vscode.ExtensionContext; 14 private extCtx: vscode.ExtensionContext;
15 private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = []; 15 private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = [];
16 16
17 constructor(extCtx: vscode.ExtensionContext) { 17 constructor(extCtx: vscode.ExtensionContext) {
18 this.config = new Config(extCtx) 18 this.config = new Config(extCtx);
19 this.extCtx = extCtx; 19 this.extCtx = extCtx;
20 } 20 }
21 21
22 async restartServer() { 22 async restartServer() {
23 let old = this.client; 23 let old = this.client;
24 if (old) { 24 if (old) {
25 await old.stop() 25 await old.stop();
26 } 26 }
27 this.client = null; 27 this.client = null;
28 const client = createClient(this.config); 28 const client = createClient(this.config);
29 this.pushCleanup(client.start()); 29 this.pushCleanup(client.start());
30 await client.onReady(); 30 await client.onReady();
31 31
32 this.client = client 32 this.client = client;
33 for (const hook of this.onDidRestartHooks) { 33 for (const hook of this.onDidRestartHooks) {
34 hook(client) 34 hook(client);
35 } 35 }
36 } 36 }
37 37
@@ -80,7 +80,7 @@ export class Ctx {
80 } 80 }
81 81
82 onDidRestart(hook: (client: lc.LanguageClient) => void) { 82 onDidRestart(hook: (client: lc.LanguageClient) => void) {
83 this.onDidRestartHooks.push(hook) 83 this.onDidRestartHooks.push(hook);
84 } 84 }
85} 85}
86 86
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index f9d2e9d90..014e96f75 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -30,7 +30,7 @@ export function activateHighlighting(ctx: Ctx) {
30 highlighter.setHighlights(targetEditor, params.decorations); 30 highlighter.setHighlights(targetEditor, params.decorations);
31 }, 31 },
32 ); 32 );
33 }) 33 });
34 34
35 vscode.workspace.onDidChangeConfiguration( 35 vscode.workspace.onDidChangeConfiguration(
36 _ => highlighter.removeHighlights(), 36 _ => highlighter.removeHighlights(),
@@ -173,13 +173,13 @@ class Highlighter {
173 173
174function initDecorations(): Map<string, vscode.TextEditorDecorationType> { 174function initDecorations(): Map<string, vscode.TextEditorDecorationType> {
175 const theme = ColorTheme.load(); 175 const theme = ColorTheme.load();
176 const res = new Map() 176 const res = new Map();
177 TAG_TO_SCOPES.forEach((scopes, tag) => { 177 TAG_TO_SCOPES.forEach((scopes, tag) => {
178 if (!scopes) throw `unmapped tag: ${tag}` 178 if (!scopes) throw `unmapped tag: ${tag}`;
179 let rule = theme.lookup(scopes) 179 let rule = theme.lookup(scopes);
180 const decor = createDecorationFromTextmate(rule); 180 const decor = createDecorationFromTextmate(rule);
181 res.set(tag, decor) 181 res.set(tag, decor);
182 }) 182 });
183 return res; 183 return res;
184} 184}
185 185
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index e74d6996f..6dd767d72 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -19,7 +19,7 @@ export function activateInlayHints(ctx: Ctx) {
19 hintsUpdater.setEnabled(ctx.config.displayInlayHints); 19 hintsUpdater.setEnabled(ctx.config.displayInlayHints);
20 }, ctx.subscriptions); 20 }, ctx.subscriptions);
21 21
22 ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)) 22 ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints));
23} 23}
24 24
25interface InlayHintsParams { 25interface InlayHintsParams {
@@ -96,7 +96,7 @@ class HintsUpdater {
96 96
97 private async queryHints(documentUri: string): Promise<InlayHint[] | null> { 97 private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
98 let client = this.ctx.client; 98 let client = this.ctx.client;
99 if (!client) return null 99 if (!client) return null;
100 const request: InlayHintsParams = { 100 const request: InlayHintsParams = {
101 textDocument: { uri: documentUri }, 101 textDocument: { uri: documentUri },
102 }; 102 };
diff --git a/editors/code/src/source_change.ts b/editors/code/src/source_change.ts
index 887191d9e..a336269ba 100644
--- a/editors/code/src/source_change.ts
+++ b/editors/code/src/source_change.ts
@@ -11,7 +11,7 @@ export interface SourceChange {
11 11
12export async function applySourceChange(ctx: Ctx, change: SourceChange) { 12export async function applySourceChange(ctx: Ctx, change: SourceChange) {
13 const client = ctx.client; 13 const client = ctx.client;
14 if (!client) return 14 if (!client) return;
15 15
16 const wsEdit = client.protocol2CodeConverter.asWorkspaceEdit( 16 const wsEdit = client.protocol2CodeConverter.asWorkspaceEdit(
17 change.workspaceEdit, 17 change.workspaceEdit,
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts
index 1454bf8b0..08cdc8bdf 100644
--- a/editors/code/src/status_display.ts
+++ b/editors/code/src/status_display.ts
@@ -9,7 +9,7 @@ export function activateStatusDisplay(ctx: Ctx) {
9 ctx.pushCleanup(statusDisplay); 9 ctx.pushCleanup(statusDisplay);
10 ctx.onDidRestart(client => { 10 ctx.onDidRestart(client => {
11 client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params)); 11 client.onNotification('$/progress', params => statusDisplay.handleProgressNotification(params));
12 }) 12 });
13} 13}
14 14
15class StatusDisplay implements vscode.Disposable { 15class StatusDisplay implements vscode.Disposable {