vscode: renamed langServer to server

This commit is contained in:
Veetaha 2020-02-15 00:42:32 +02:00
parent f61134e198
commit 80d5ba68da
3 changed files with 22 additions and 22 deletions

View file

@ -2,7 +2,7 @@ import * as lc from 'vscode-languageclient';
import * as vscode from 'vscode';
import { Config } from './config';
import { ensureLangServerBinary } from './installation/lang_server';
import { ensureServerBinary } from './installation/server';
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
export async function createClient(config: Config): Promise<null | lc.LanguageClient> {
@ -11,11 +11,11 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
// It might be a good idea to test if the uri points to a file.
const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
const langServerPath = await ensureLangServerBinary(config.langServerBinarySource);
if (!langServerPath) return null;
const serverPath = await ensureServerBinary(config.serverBinarySource);
if (!serverPath) return null;
const run: lc.Executable = {
command: langServerPath,
command: serverPath,
options: { cwd: workspaceFolderPath },
};
const serverOptions: lc.ServerOptions = {

View file

@ -68,7 +68,7 @@ export class Config {
* `platform` on GitHub releases. (It is also stored under the same name when
* downloaded by the extension).
*/
get prebuiltLangServerFileName(): null | string {
get prebuiltServerFileName(): null | string {
// See possible `arch` values here:
// https://nodejs.org/api/process.html#process_process_arch
@ -98,17 +98,17 @@ export class Config {
}
}
get langServerBinarySource(): null | BinarySource {
const langServerPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath");
get serverBinarySource(): null | BinarySource {
const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath");
if (langServerPath) {
if (serverPath) {
return {
type: BinarySource.Type.ExplicitPath,
path: Config.replaceTildeWithHomeDir(langServerPath)
path: Config.replaceTildeWithHomeDir(serverPath)
};
}
const prebuiltBinaryName = this.prebuiltLangServerFileName;
const prebuiltBinaryName = this.prebuiltServerFileName;
if (!prebuiltBinaryName) return null;

View file

@ -10,7 +10,7 @@ import { BinarySource } from "./interfaces";
import { fetchLatestArtifactReleaseInfo } from "./fetch_latest_artifact_release_info";
import { downloadFile } from "./download_file";
export async function downloadLatestLangServer(
export async function downloadLatestServer(
{file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease
) {
const { releaseName, downloadUrl } = (await fetchLatestArtifactReleaseInfo(
@ -53,11 +53,11 @@ export async function downloadLatestLangServer(
);
console.timeEnd("Downloading ra_lsp_server");
}
export async function ensureLangServerBinary(
langServerSource: null | BinarySource
export async function ensureServerBinary(
serverSource: null | BinarySource
): Promise<null | string> {
if (!langServerSource) {
if (!serverSource) {
vscode.window.showErrorMessage(
"Unfortunately we don't ship binaries for your platform yet. " +
"You need to manually clone rust-analyzer repository and " +
@ -69,21 +69,21 @@ export async function ensureLangServerBinary(
return null;
}
switch (langServerSource.type) {
switch (serverSource.type) {
case BinarySource.Type.ExplicitPath: {
if (isBinaryAvailable(langServerSource.path)) {
return langServerSource.path;
if (isBinaryAvailable(serverSource.path)) {
return serverSource.path;
}
vscode.window.showErrorMessage(
`Unable to run ${langServerSource.path} binary. ` +
`Unable to run ${serverSource.path} binary. ` +
`To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` +
"value to `null` or remove it from the settings to use it by default."
);
return null;
}
case BinarySource.Type.GithubRelease: {
const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file);
const prebuiltBinaryPath = path.join(serverSource.dir, serverSource.file);
if (isBinaryAvailable(prebuiltBinaryPath)) {
return prebuiltBinaryPath;
@ -97,10 +97,10 @@ export async function ensureLangServerBinary(
if (userResponse !== "Download now") return null;
try {
await downloadLatestLangServer(langServerSource);
await downloadLatestServer(serverSource);
} catch (err) {
vscode.window.showErrorMessage(
`Failed to download language server from ${langServerSource.repo.name} ` +
`Failed to download language server from ${serverSource.repo.name} ` +
`GitHub repository: ${err.message}`
);
@ -122,7 +122,7 @@ export async function ensureLangServerBinary(
if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
`Downloaded language server binary is not functional.` +
`Downloaded from: ${JSON.stringify(langServerSource)}`
`Downloaded from: ${JSON.stringify(serverSource)}`
);