mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Merge #3131
3131: vscode: simplified config and to removed one source of truth of default values r=matklad a=Veetaha Though not intended initially, the implementation of config design is alike [dart's one](https://github.com/Dart-Code/Dart-Code/blob/master/src/extension/config.ts) as pointed by @matklad in PM. Co-authored-by: Veetaha <gerzoh1@gmail.com>
This commit is contained in:
commit
ab42174653
4 changed files with 98 additions and 213 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as lc from 'vscode-languageclient';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { window, workspace } from 'vscode';
|
||||
import { Config } from './config';
|
||||
import { ensureLanguageServerBinary } from './installation/language_server';
|
||||
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
||||
|
@ -9,32 +9,34 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
|
|||
// '.' Is the fallback if no folder is open
|
||||
// TODO?: Workspace folders support Uri's (eg: file://test.txt).
|
||||
// It might be a good idea to test if the uri points to a file.
|
||||
const workspaceFolderPath = workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
|
||||
const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
|
||||
|
||||
const raLspServerPath = await ensureLanguageServerBinary(config.langServerSource);
|
||||
if (!raLspServerPath) return null;
|
||||
const langServerPath = await ensureLanguageServerBinary(config.langServerBinarySource);
|
||||
if (!langServerPath) return null;
|
||||
|
||||
const run: lc.Executable = {
|
||||
command: raLspServerPath,
|
||||
command: langServerPath,
|
||||
options: { cwd: workspaceFolderPath },
|
||||
};
|
||||
const serverOptions: lc.ServerOptions = {
|
||||
run,
|
||||
debug: run,
|
||||
};
|
||||
const traceOutputChannel = window.createOutputChannel(
|
||||
const traceOutputChannel = vscode.window.createOutputChannel(
|
||||
'Rust Analyzer Language Server Trace',
|
||||
);
|
||||
const cargoWatchOpts = config.cargoWatchOptions;
|
||||
|
||||
const clientOptions: lc.LanguageClientOptions = {
|
||||
documentSelector: [{ scheme: 'file', language: 'rust' }],
|
||||
initializationOptions: {
|
||||
publishDecorations: true,
|
||||
lruCapacity: config.lruCapacity,
|
||||
maxInlayHintLength: config.maxInlayHintLength,
|
||||
cargoWatchEnable: config.cargoWatchOptions.enable,
|
||||
cargoWatchArgs: config.cargoWatchOptions.arguments,
|
||||
cargoWatchCommand: config.cargoWatchOptions.command,
|
||||
cargoWatchAllTargets: config.cargoWatchOptions.allTargets,
|
||||
cargoWatchEnable: cargoWatchOpts.enable,
|
||||
cargoWatchArgs: cargoWatchOpts.arguments,
|
||||
cargoWatchCommand: cargoWatchOpts.command,
|
||||
cargoWatchAllTargets: cargoWatchOpts.allTargets,
|
||||
excludeGlobs: config.excludeGlobs,
|
||||
useClientWatching: config.useClientWatching,
|
||||
featureFlags: config.featureFlags,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue