blob: afc5cc6aff68ab8f71deff5e9edf893b3891f49a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import * as vscode from 'vscode';
import { Server } from './server';
const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
export class Config {
public highlightingOn = true;
public enableEnhancedTyping = true;
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
public showWorkspaceLoadedNotification = true;
private prevEnhancedTyping: null | boolean = null;
constructor() {
vscode.workspace.onDidChangeConfiguration(_ =>
this.userConfigChanged()
);
this.userConfigChanged();
}
public userConfigChanged() {
const config = vscode.workspace.getConfiguration('rust-analyzer');
if (config.has('highlightingOn')) {
this.highlightingOn = config.get('highlightingOn') as boolean;
}
if (config.has('showWorkspaceLoadedNotification')) {
this.showWorkspaceLoadedNotification = config.get(
'showWorkspaceLoadedNotification'
) as boolean;
}
if (!this.highlightingOn && Server) {
Server.highlighter.removeHighlights();
}
if (config.has('enableEnhancedTyping')) {
this.enableEnhancedTyping = config.get(
'enableEnhancedTyping'
) as boolean;
if (this.prevEnhancedTyping === null) {
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
} else if (this.prevEnhancedTyping === null) {
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
if (this.prevEnhancedTyping !== this.enableEnhancedTyping) {
const reloadAction = 'Reload now';
vscode.window
.showInformationMessage(
'Changing enhanced typing setting requires a reload',
reloadAction
)
.then(selectedAction => {
if (selectedAction === reloadAction) {
vscode.commands.executeCommand(
'workbench.action.reloadWindow'
);
}
});
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
if (config.has('raLspServerPath')) {
this.raLspServerPath =
RA_LSP_DEBUG || (config.get('raLspServerPath') as string);
}
}
}
|