mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Substitute some VSCode variables in the VSCode client
This commit is contained in:
parent
ee2d9eddb6
commit
d5f467aa4a
2 changed files with 79 additions and 32 deletions
|
@ -5,7 +5,7 @@ import * as Is from "vscode-languageclient/lib/common/utils/is";
|
|||
import { assert } from "./util";
|
||||
import { WorkspaceEdit } from "vscode";
|
||||
import { Workspace } from "./ctx";
|
||||
import { substituteVariablesInEnv } from "./config";
|
||||
import { substituteVariablesInEnv, substituteVSCodeVariables } from "./config";
|
||||
import { outputChannel, traceOutputChannel } from "./main";
|
||||
import { randomUUID } from "crypto";
|
||||
|
||||
|
@ -83,15 +83,17 @@ export async function createClient(
|
|||
debug: run,
|
||||
};
|
||||
|
||||
let initializationOptions = vscode.workspace.getConfiguration("rust-analyzer");
|
||||
let rawInitializationOptions = vscode.workspace.getConfiguration("rust-analyzer");
|
||||
|
||||
if (workspace.kind === "Detached Files") {
|
||||
initializationOptions = {
|
||||
rawInitializationOptions = {
|
||||
detachedFiles: workspace.files.map((file) => file.uri.fsPath),
|
||||
...initializationOptions,
|
||||
...rawInitializationOptions,
|
||||
};
|
||||
}
|
||||
|
||||
const initializationOptions = substituteVSCodeVariables(rawInitializationOptions);
|
||||
|
||||
const clientOptions: lc.LanguageClientOptions = {
|
||||
documentSelector: [{ scheme: "file", language: "rust" }],
|
||||
initializationOptions,
|
||||
|
@ -99,6 +101,22 @@ export async function createClient(
|
|||
traceOutputChannel: traceOutputChannel(),
|
||||
outputChannel: outputChannel(),
|
||||
middleware: {
|
||||
workspace: {
|
||||
async configuration(
|
||||
params: lc.ConfigurationParams,
|
||||
token: vscode.CancellationToken,
|
||||
next: lc.ConfigurationRequest.HandlerSignature
|
||||
) {
|
||||
const resp = await next(params, token);
|
||||
if (resp && Array.isArray(resp)) {
|
||||
return resp.map((val) => {
|
||||
return substituteVSCodeVariables(val);
|
||||
});
|
||||
} else {
|
||||
return resp;
|
||||
}
|
||||
},
|
||||
},
|
||||
async provideHover(
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue