2018-10-07 22:59:02 +02:00
|
|
|
import * as vscode from 'vscode';
|
|
|
|
|
|
|
|
import { Server } from './server';
|
|
|
|
|
2019-01-18 11:59:08 +01:00
|
|
|
const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
|
|
|
|
|
2018-10-07 22:59:02 +02:00
|
|
|
export class Config {
|
2018-10-08 23:38:33 +02:00
|
|
|
public highlightingOn = true;
|
2019-01-18 11:59:08 +01:00
|
|
|
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
|
2018-10-07 22:59:02 +02:00
|
|
|
|
2018-10-08 23:38:33 +02:00
|
|
|
constructor() {
|
|
|
|
vscode.workspace.onDidChangeConfiguration(_ =>
|
|
|
|
this.userConfigChanged()
|
|
|
|
);
|
|
|
|
this.userConfigChanged();
|
2018-10-08 23:36:47 +02:00
|
|
|
}
|
2018-10-07 22:59:02 +02:00
|
|
|
|
2018-10-08 23:38:33 +02:00
|
|
|
public userConfigChanged() {
|
2019-01-28 12:43:07 +01:00
|
|
|
const config = vscode.workspace.getConfiguration('rust-analyzer');
|
2018-10-08 23:38:33 +02:00
|
|
|
if (config.has('highlightingOn')) {
|
|
|
|
this.highlightingOn = config.get('highlightingOn') as boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.highlightingOn && Server) {
|
|
|
|
Server.highlighter.removeHighlights();
|
|
|
|
}
|
2019-01-05 16:28:41 +01:00
|
|
|
|
|
|
|
if (config.has('raLspServerPath')) {
|
2019-01-18 11:59:08 +01:00
|
|
|
this.raLspServerPath =
|
|
|
|
RA_LSP_DEBUG || (config.get('raLspServerPath') as string);
|
2019-01-05 16:28:41 +01:00
|
|
|
}
|
2018-10-07 22:59:02 +02:00
|
|
|
}
|
|
|
|
}
|