дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
feat(vue): pick the managed Vue language server version per project (#7513)
Vue 2 projects (detected from package.json, or the installed vue for alias/workspace specs) use vue-language-server 3.0.x, which still supports Vue 2; other projects use latest. Each release installs in its own directory with its paired TypeScript. A version setting overrides detection. Fixes #7357
Цей коміт міститься в:
1 джерело
b911366115
коміт
95bc3622ab
12 files changed
+348
-14
No files matched your search
@@ -705,6 +705,8 @@ pub struct ToolDownloadSettings {
|
||||
/// Maven Central, dependency version completion from Maven Central, npm, PyPI and
|
||||
/// crates.io). Off by default.
|
||||
pub configured_registries_only: bool,
|
||||
/// The managed Vue Language Server release. Empty selects it from the project's Vue dependency.
|
||||
pub vue_language_server_version: String,
|
||||
}
|
||||
|
||||
/// Settings › Settings Sync: the Git repository the IDE settings sync through, and what syncs.
|
||||
|
||||
@@ -115,6 +115,23 @@ pub struct Project {
|
||||
pub light: bool,
|
||||
}
|
||||
|
||||
/// Selects the same managed Vue executable for Volar and the vtsls companion plugin.
|
||||
fn configure_vue_release(settings: &mut ide_core::settings::Settings, project_root: &Path, app_data: &Path) {
|
||||
let name = ide_tools::vue::SERVER;
|
||||
if settings.tool_path(name).is_some()
|
||||
|| settings.language_servers.get(name).is_some_and(|entry| !entry.command.trim().is_empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
let release = ide_tools::vue::release(Some(project_root), &settings.tool_downloads.vue_language_server_version);
|
||||
if release != "latest" {
|
||||
let path = ide_tools::vue::managed_command(app_data, release);
|
||||
settings
|
||||
.tools
|
||||
.insert(name.into(), ide_core::settings::ToolSettings { path: path.to_string_lossy().into_owned() });
|
||||
}
|
||||
}
|
||||
|
||||
impl Host {
|
||||
pub fn open_project(&self, window: &str, root: &Path) -> IdeResult<Arc<Project>> {
|
||||
let started = std::time::Instant::now();
|
||||
@@ -241,12 +258,15 @@ impl Host {
|
||||
let member = ide_workspace::workspace::Workspace::load(&root).ok().flatten().and_then(|w| {
|
||||
w.projects.into_iter().filter(|p| server_root.starts_with(p)).max_by_key(|p| p.components().count())
|
||||
});
|
||||
let effective = member
|
||||
let mut effective = member
|
||||
.as_ref()
|
||||
.map(|p| SettingsStore::load(&config_dir, Some(p)).effective())
|
||||
.unwrap_or_else(|| settings.effective());
|
||||
let window_root = &root;
|
||||
let root = member.as_ref().unwrap_or(window_root);
|
||||
if matches!(cfg.name.as_str(), "vue-language-server" | "vtsls" | "typescript-language-server") {
|
||||
configure_vue_release(&mut effective, root, &data_dir);
|
||||
}
|
||||
ide_sdk::apply::server_launch_overrides(cfg, &effective);
|
||||
ide_sdk::apply::configure_server(cfg, root, server_root, &effective);
|
||||
ide_sdk::json_schemas::configure(cfg, root, &effective.json_schemas);
|
||||
@@ -2834,6 +2854,38 @@ fn notify_transfer(sink: &SharedSink, what: &str, path: &Path, result: IdeResult
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod vue_release_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn vue_release_configures_the_managed_command_and_respects_explicit_settings() {
|
||||
let project = tempfile::tempdir().unwrap();
|
||||
let root = project.path();
|
||||
std::fs::write(root.join("package.json"), r#"{"dependencies":{"vue":"^2.7.16"}}"#).unwrap();
|
||||
let app_data = root.join("data");
|
||||
let mut settings = ide_core::settings::Settings::default();
|
||||
configure_vue_release(&mut settings, root, &app_data);
|
||||
let name = ide_tools::vue::SERVER;
|
||||
assert_eq!(
|
||||
ide_sdk::apply::tool_command(root, &settings, name),
|
||||
Some(ide_tools::vue::managed_command(&app_data, "3.0.x")),
|
||||
);
|
||||
|
||||
let mut settings = ide_core::settings::Settings::default();
|
||||
settings.tool_downloads.vue_language_server_version = "3.1.2".into();
|
||||
configure_vue_release(&mut settings, root, &app_data);
|
||||
assert_eq!(
|
||||
ide_sdk::apply::tool_command(root, &settings, name),
|
||||
Some(ide_tools::vue::managed_command(&app_data, "3.1.2")),
|
||||
);
|
||||
|
||||
settings.tools.get_mut(name).unwrap().path = "custom-vue".into();
|
||||
configure_vue_release(&mut settings, root, &app_data);
|
||||
assert_eq!(ide_sdk::apply::tool_command(root, &settings, name), Some(root.join("custom-vue")));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod maven_linkage_tests {
|
||||
#[test]
|
||||
|
||||
@@ -29,6 +29,7 @@ mod process;
|
||||
pub mod registry;
|
||||
pub mod server;
|
||||
pub mod sources;
|
||||
pub mod vue;
|
||||
|
||||
use ide_core::error::ErrorKind;
|
||||
use ide_core::settings::ToolDownloadSettings;
|
||||
@@ -502,6 +503,7 @@ pub struct Tools {
|
||||
/// The project the tools are used for: tools that install into "the active runtime" (gems) run here,
|
||||
/// so a version manager picks the project's Ruby.
|
||||
work_dir: Option<PathBuf>,
|
||||
vue_version: Option<String>,
|
||||
/// Tools › Download sources: the mirror prefix and its fallback behaviour.
|
||||
downloads: ToolDownloadSettings,
|
||||
}
|
||||
@@ -528,6 +530,7 @@ impl Tools {
|
||||
runtime_env: BTreeMap::new(),
|
||||
version_timeout: Duration::from_secs(4),
|
||||
work_dir: None,
|
||||
vue_version: None,
|
||||
downloads: ToolDownloadSettings::default(),
|
||||
}
|
||||
}
|
||||
@@ -778,9 +781,29 @@ impl Tools {
|
||||
}
|
||||
}
|
||||
|
||||
fn vue_release(&self) -> &str {
|
||||
vue::release(self.work_dir.as_deref(), &self.downloads.vue_language_server_version)
|
||||
}
|
||||
|
||||
fn for_tool(&self, spec: &ToolSpec) -> Self {
|
||||
let mut tools = self.for_method(spec.method);
|
||||
if spec.name == vue::SERVER && self.vue_version.is_none() {
|
||||
let release = self.vue_release();
|
||||
if release != "latest" {
|
||||
tools.root = vue::managed_prefix(&tools.root, release);
|
||||
tools.vue_version = Some(release.to_owned());
|
||||
}
|
||||
}
|
||||
tools
|
||||
}
|
||||
|
||||
fn install_key(&self, name: &str) -> String {
|
||||
self.vue_version.as_ref().map_or_else(|| name.to_owned(), |release| format!("{name}@{release}"))
|
||||
}
|
||||
|
||||
fn info_for(&self, name: &str, usage: Option<&Usage>) -> Option<ToolInfo> {
|
||||
match registry::find(name) {
|
||||
Some(spec) => self.for_method(spec.method).info_for_runtime(name, usage),
|
||||
Some(spec) => self.for_tool(spec).info_for_runtime(name, usage),
|
||||
None => self.info_for_runtime(name, usage),
|
||||
}
|
||||
}
|
||||
@@ -896,6 +919,9 @@ impl Tools {
|
||||
.or_else(|| self.query_version(spec, &path));
|
||||
return (ToolStatus::Installed, Some(path), version);
|
||||
}
|
||||
if self.vue_version.is_some() {
|
||||
return (ToolStatus::Missing, None, None);
|
||||
}
|
||||
match self.install_method(spec) {
|
||||
Method::Rustup { .. } => {
|
||||
let Some(path) = self.which(main) else { return (ToolStatus::Missing, None, None) };
|
||||
@@ -1004,7 +1030,7 @@ impl Tools {
|
||||
emit: Emit,
|
||||
) -> IdeResult<ToolInfo> {
|
||||
match registry::find(name) {
|
||||
Some(spec) => self.for_method(spec.method).install_for_runtime(name, langs, cancel, emit),
|
||||
Some(spec) => self.for_tool(spec).install_for_runtime(name, langs, cancel, emit),
|
||||
None => self.install_for_runtime(name, langs, cancel, emit),
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1052,8 @@ impl Tools {
|
||||
if let Some(reason) = self.unavailable_reason(spec) {
|
||||
return Err(IdeError::unavailable(reason));
|
||||
}
|
||||
let slot = match install_slot(name, cancel) {
|
||||
let install_key = self.install_key(name);
|
||||
let slot = match install_slot(&install_key, cancel) {
|
||||
Ok(slot) => slot,
|
||||
Err(slot) => return join_install(&slot, cancel, emit),
|
||||
};
|
||||
@@ -1053,7 +1080,16 @@ impl Tools {
|
||||
c.args(["component", "add", component]);
|
||||
run_streamed(c, cancel, emit)?;
|
||||
}
|
||||
Method::Npm { packages } => self.install_npm(packages, cancel, emit)?,
|
||||
Method::Npm { packages } => {
|
||||
if let Some(release) = &self.vue_version {
|
||||
let primary = format!("{}@{release}", vue::PACKAGE);
|
||||
let mut packages = packages.to_vec();
|
||||
packages[0] = &primary;
|
||||
self.install_npm(&packages, cancel, emit)?;
|
||||
} else {
|
||||
self.install_npm(packages, cancel, emit)?;
|
||||
}
|
||||
}
|
||||
Method::Go { module } => self.install_go(spec, module, cancel, emit)?,
|
||||
Method::Gem { gem } => self.install_gem(spec, gem, cancel, emit)?,
|
||||
Method::GemActive { gem } => self.install_gem_active(gem, cancel, emit)?,
|
||||
@@ -1081,7 +1117,7 @@ impl Tools {
|
||||
});
|
||||
Ok(info)
|
||||
})();
|
||||
release_install_slot(name, &slot);
|
||||
release_install_slot(&install_key, &slot);
|
||||
slot.finish(result.clone());
|
||||
result
|
||||
}
|
||||
@@ -1720,6 +1756,10 @@ impl Tools {
|
||||
let installed: Vec<(&ToolSpec, Method, String)> = TOOLS
|
||||
.iter()
|
||||
.filter_map(|spec| {
|
||||
// Alternate Vue releases are version constraints, like pinned npm packages.
|
||||
if spec.name == vue::SERVER && self.vue_release() != "latest" {
|
||||
return None;
|
||||
}
|
||||
let method = self.install_method(spec);
|
||||
Some((spec, method, self.installed_version(spec, method)?))
|
||||
})
|
||||
@@ -1801,7 +1841,7 @@ impl Tools {
|
||||
/// Removes a tool the IDE installed.
|
||||
pub fn uninstall(&self, name: &str, langs: &[LanguageConfig]) -> IdeResult<ToolInfo> {
|
||||
match registry::find(name) {
|
||||
Some(spec) => self.for_method(spec.method).uninstall_for_runtime(name, langs),
|
||||
Some(spec) => self.for_tool(spec).uninstall_for_runtime(name, langs),
|
||||
None => self.uninstall_for_runtime(name, langs),
|
||||
}
|
||||
}
|
||||
@@ -1809,10 +1849,11 @@ impl Tools {
|
||||
fn uninstall_for_runtime(&self, name: &str, langs: &[LanguageConfig]) -> IdeResult<ToolInfo> {
|
||||
let spec = registry::find(name).ok_or_else(|| IdeError::not_found(format!("unknown tool `{name}`")))?;
|
||||
// Uninstalling mid-install would tear down the directory under the running installer.
|
||||
if INSTALLING.lock().as_ref().is_some_and(|m| m.contains_key(name)) {
|
||||
let install_key = self.install_key(name);
|
||||
if INSTALLING.lock().as_ref().is_some_and(|m| m.contains_key(&install_key)) {
|
||||
return Err(IdeError::new(ErrorKind::AlreadyExists, format!("{name} is already being installed")));
|
||||
}
|
||||
let _guard = InstallGuard::acquire(&format!("uninstall-{name}"))?;
|
||||
let _guard = InstallGuard::acquire(&format!("uninstall-{install_key}"))?;
|
||||
let cancel = CancellationToken::new();
|
||||
let quiet = |_: InstallEvent| {};
|
||||
match self.install_method(spec) {
|
||||
|
||||
@@ -642,6 +642,52 @@ exit 1"#,
|
||||
assert!(!calls.contains("registry.npmjs.org"), "{calls}");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn vue_installs_the_selected_release_without_replacing_other_projects() {
|
||||
let env = Env::new();
|
||||
env.script(&env.sys, "node", "exit 0");
|
||||
env.script(
|
||||
&env.sys,
|
||||
"npm",
|
||||
r#"prefix=""; version=""
|
||||
for arg in "$@"; do
|
||||
[ "$previous" = "--prefix" ] && prefix="$arg"
|
||||
case "$arg" in
|
||||
@vue/language-server@3.0.x) version=3.0.8;;
|
||||
@vue/language-server@3.1.2) version=3.1.2;;
|
||||
@vue/language-server@latest) version=3.2.0;;
|
||||
esac
|
||||
previous="$arg"
|
||||
done
|
||||
[ -n "$version" ] || exit 1
|
||||
/bin/mkdir -p "$prefix/node_modules/.bin" "$prefix/node_modules/@vue/language-server"
|
||||
printf '{"version":"%s"}\n' "$version" > "$prefix/node_modules/@vue/language-server/package.json"
|
||||
printf '#!/bin/sh\necho %s\n' "$version" > "$prefix/node_modules/.bin/vue-language-server"
|
||||
/bin/chmod +x "$prefix/node_modules/.bin/vue-language-server""#,
|
||||
);
|
||||
let project = env._tmp.path().join("vue-two");
|
||||
fs::create_dir(&project).unwrap();
|
||||
fs::write(project.join("package.json"), r#"{"dependencies":{"vue":"^2.7.16"}}"#).unwrap();
|
||||
let tools = env.tools();
|
||||
let legacy = tools.clone().with_work_dir(Some(project));
|
||||
let manual = legacy
|
||||
.clone()
|
||||
.with_downloads(ToolDownloadSettings { vue_language_server_version: "3.1.2".into(), ..Default::default() });
|
||||
let install = |tools: &Tools| tools.install(vue::SERVER, &langs(), &CancellationToken::new(), &|_| {}).unwrap();
|
||||
let stable_info = install(&tools);
|
||||
let legacy_info = install(&legacy);
|
||||
let manual_info = install(&manual);
|
||||
assert_eq!(stable_info.version.as_deref(), Some("3.2.0"));
|
||||
assert_eq!(legacy_info.version.as_deref(), Some("3.0.8"));
|
||||
assert_eq!(manual_info.version.as_deref(), Some("3.1.2"));
|
||||
let path = |release| vue::managed_command(env.root.parent().unwrap(), release);
|
||||
assert_eq!(legacy_info.path.as_deref(), Some(path("3.0.x").as_path()));
|
||||
assert_eq!(manual_info.path.as_deref(), Some(path("3.1.2").as_path()));
|
||||
assert_eq!(tools.info_for(vue::SERVER, None).unwrap().version.as_deref(), Some("3.2.0"));
|
||||
assert_eq!(legacy.info_for(vue::SERVER, None).unwrap().version.as_deref(), Some("3.0.8"));
|
||||
}
|
||||
|
||||
/// Servers that load TypeScript as a library get one with its JS API: `@latest`
|
||||
/// is TypeScript 7 (native, no `ts.server`), which crashed vue-language-server (#25).
|
||||
/// Uninstalling one keeps the TypeScript another installed server still uses.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
//! Select and locate an isolated managed Vue language-server version.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub const SERVER: &str = "vue-language-server";
|
||||
pub(crate) const PACKAGE: &str = "@vue/language-server";
|
||||
const LEGACY: &str = "3.0.x";
|
||||
|
||||
/// A chosen version wins over project detection. Invalid values are never given to npm.
|
||||
pub fn release<'a>(project: Option<&Path>, preferred: &'a str) -> &'a str {
|
||||
let preferred = preferred.trim();
|
||||
if preferred == "latest" || preferred == LEGACY || exact_version(preferred) {
|
||||
return preferred;
|
||||
}
|
||||
if project.and_then(uses_vue_two) == Some(true) { LEGACY } else { "latest" }
|
||||
}
|
||||
|
||||
fn exact_version(value: &str) -> bool {
|
||||
let (release, build) = value.split_once('+').map_or((value, None), |(a, b)| (a, Some(b)));
|
||||
let (core, pre) = release.split_once('-').map_or((release, None), |(a, b)| (a, Some(b)));
|
||||
let valid_suffix = |suffix: &str| {
|
||||
suffix.split('.').all(|part| !part.is_empty() && part.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-'))
|
||||
};
|
||||
core.split('.').count() == 3
|
||||
&& core.split('.').all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit()))
|
||||
&& pre.is_none_or(valid_suffix)
|
||||
&& build.is_none_or(valid_suffix)
|
||||
}
|
||||
|
||||
fn read_manifest(path: &Path) -> Option<serde_json::Value> {
|
||||
serde_json::from_slice(&std::fs::read(path).ok()?).ok()
|
||||
}
|
||||
|
||||
fn uses_vue_two(project: &Path) -> Option<bool> {
|
||||
let manifest = read_manifest(&project.join("package.json"))?;
|
||||
let dependency = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]
|
||||
.iter()
|
||||
.find_map(|group| manifest[*group]["vue"].as_str())?;
|
||||
let dependency = dependency.trim().strip_prefix("npm:vue@").unwrap_or(dependency.trim());
|
||||
if !matches!(dependency, "" | "*" | "latest" | "workspace:*" | "workspace:^" | "workspace:~")
|
||||
&& !["file:", "link:", "git:", "https:", "npm:"].iter().any(|&prefix| dependency.starts_with(prefix))
|
||||
{
|
||||
return Some(dependency.strip_prefix("workspace:").unwrap_or(dependency).split("||").all(vue_two_range));
|
||||
}
|
||||
// A package-manager alias or workspace range may only identify its version once installed.
|
||||
let installed = read_manifest(&project.join("node_modules/vue/package.json"));
|
||||
Some(installed.as_ref().and_then(|p| p["version"].as_str()).is_some_and(vue_two_range))
|
||||
}
|
||||
|
||||
fn vue_two_range(value: &str) -> bool {
|
||||
let value = value.trim();
|
||||
let major_two = |version: &str| {
|
||||
let version = version.trim().trim_start_matches(['=', '^', '~', 'v']).trim();
|
||||
version == "2" || version.starts_with("2.")
|
||||
};
|
||||
if let Some((_, limit)) = value.split_once('<') {
|
||||
let limit = limit.trim();
|
||||
if let Some(inclusive) = limit.strip_prefix('=') {
|
||||
if inclusive.split_whitespace().next().is_some_and(major_two) {
|
||||
return true;
|
||||
}
|
||||
} else if matches!(limit.split_whitespace().next(), Some("3" | "3.0" | "3.0.0" | "3.0.0-0")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if let Some((minimum, maximum)) = value.split_once(" - ") {
|
||||
return major_two(minimum) && major_two(maximum);
|
||||
}
|
||||
major_two(value)
|
||||
}
|
||||
|
||||
/// Extra releases stay off the process PATH and keep their own paired TypeScript package.
|
||||
pub(crate) fn managed_prefix(tools: &Path, release: &str) -> PathBuf {
|
||||
tools.join("vue-language-server-versions").join(release)
|
||||
}
|
||||
|
||||
pub fn managed_command(data: &Path, release: &str) -> PathBuf {
|
||||
managed_prefix(&crate::tools_dir(data), release).join("node_modules/.bin").join(if cfg!(windows) {
|
||||
"vue-language-server.cmd"
|
||||
} else {
|
||||
SERVER
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn project_release_and_overrides() {
|
||||
let project = tempfile::tempdir().unwrap();
|
||||
let root = project.path();
|
||||
for (version, expected) in [
|
||||
("^2.7.16", LEGACY),
|
||||
(">=2.6 <3", LEGACY),
|
||||
("<=2.7.x", LEGACY),
|
||||
("~2", LEGACY),
|
||||
("^3.4.0", "latest"),
|
||||
("^2.7.16 || ^3.4.0", "latest"),
|
||||
] {
|
||||
std::fs::write(root.join("package.json"), serde_json::json!({"dependencies":{"vue":version}}).to_string())
|
||||
.unwrap();
|
||||
assert_eq!(release(Some(root), ""), expected);
|
||||
assert_eq!(release(Some(root), "3.0.6"), "3.0.6");
|
||||
assert_eq!(release(Some(root), "latest"), "latest");
|
||||
assert_eq!(release(Some(root), "../unsafe"), expected);
|
||||
}
|
||||
assert_eq!(release(None, LEGACY), LEGACY);
|
||||
}
|
||||
}
|
||||
@@ -275,6 +275,48 @@ test("Language Servers page installs a tool with progress (in-memory installer)"
|
||||
await expect(dialog.getByLabel("solargraph details")).toContainText("gem install solargraph");
|
||||
});
|
||||
|
||||
test("Vue Language Server accepts a manual managed version in Settings", async ({ workbench: page }) => {
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/features/tools/backend.ts";
|
||||
const { MemoryToolsBackend, sampleTools, setToolsBackend } = (await import(
|
||||
/* @vite-ignore */ path
|
||||
)) as typeof import("../src/features/tools/backend");
|
||||
const sample = sampleTools().find((tool) => tool.name === "gopls")!;
|
||||
setToolsBackend(
|
||||
new MemoryToolsBackend([
|
||||
{
|
||||
...sample,
|
||||
name: "vue-language-server",
|
||||
displayName: "Vue Language Server",
|
||||
command: "vue-language-server",
|
||||
languages: ["Vue"],
|
||||
installMethod: "npm",
|
||||
},
|
||||
]),
|
||||
);
|
||||
});
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings" });
|
||||
await dialog.getByRole("textbox", { name: "Search settings" }).fill("Language Servers");
|
||||
await dialog.getByRole("treeitem", { name: "Language Servers", exact: true }).click();
|
||||
await dialog
|
||||
.getByRole("list", { name: "Languages", exact: true })
|
||||
.getByRole("button", { name: /^Vue\b/ })
|
||||
.click();
|
||||
await dialog.locator('[data-tool="vue-language-server"]').click();
|
||||
const version = dialog.getByLabel(/Vue Language Server version/);
|
||||
await expect(version).toBeEmpty();
|
||||
await version.fill("../invalid");
|
||||
await expect(version).toHaveAttribute("aria-invalid", "true");
|
||||
await version.fill("3.0.8");
|
||||
await expect(version).not.toHaveAttribute("aria-invalid", "true");
|
||||
const apply = dialog.getByRole("button", { name: "Apply", exact: true });
|
||||
await expect(apply).toBeEnabled();
|
||||
await apply.click();
|
||||
await expect(apply).toBeDisabled();
|
||||
await expect(version).toHaveValue("3.0.8");
|
||||
});
|
||||
|
||||
test("font picker supports manual families and CJK fallback in browser development", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings" });
|
||||
|
||||
@@ -17324,6 +17324,8 @@ export type ToolDownloadSettings = {
|
||||
* crates.io). Off by default.
|
||||
*/
|
||||
configuredRegistriesOnly?: boolean,
|
||||
/** The managed Vue Language Server release. Empty selects it from the project's Vue dependency. */
|
||||
vueLanguageServerVersion?: string,
|
||||
};
|
||||
|
||||
/** UI-facing state of one tool. */
|
||||
|
||||
@@ -145,7 +145,7 @@ export interface ValidSettings extends WorkflowSettings {
|
||||
proxy: ProxySettingsValid;
|
||||
remoteDevelopment: { idleTimeoutMinutes: number };
|
||||
/** Tools › Download sources: a mirror prefix for the installer's release downloads. */
|
||||
toolDownloads: { githubMirror: string; configuredRegistriesOnly: boolean };
|
||||
toolDownloads: { githubMirror: string; configuredRegistriesOnly: boolean; vueLanguageServerVersion: string };
|
||||
/** Settings Sync (global): the repository and the categories that sync. */
|
||||
settingsSync: SettingsSyncValid;
|
||||
languages: LanguagesValid;
|
||||
@@ -273,7 +273,7 @@ export const DEFAULT_SETTINGS: ValidSettings = {
|
||||
notifications: DEFAULT_NOTIFICATIONS,
|
||||
proxy: DEFAULT_PROXY,
|
||||
remoteDevelopment: { idleTimeoutMinutes: DEFAULT_REMOTE_IDLE_MINUTES },
|
||||
toolDownloads: { githubMirror: "", configuredRegistriesOnly: false },
|
||||
toolDownloads: { githubMirror: "", configuredRegistriesOnly: false, vueLanguageServerVersion: "" },
|
||||
settingsSync: DEFAULT_SETTINGS_SYNC,
|
||||
languages: DEFAULT_LANGUAGES,
|
||||
cmake: {},
|
||||
@@ -574,6 +574,10 @@ export function validateSettings(raw: Settings | unknown): ValidSettings {
|
||||
? String(obj(root.toolDownloads).githubMirror).trim()
|
||||
: "",
|
||||
configuredRegistriesOnly: obj(root.toolDownloads).configuredRegistriesOnly === true,
|
||||
vueLanguageServerVersion:
|
||||
typeof obj(root.toolDownloads).vueLanguageServerVersion === "string"
|
||||
? String(obj(root.toolDownloads).vueLanguageServerVersion).trim()
|
||||
: "",
|
||||
},
|
||||
settingsSync: Object.fromEntries(
|
||||
Object.entries(DEFAULT_SETTINGS_SYNC).map(([key, fallback]) => {
|
||||
|
||||
@@ -656,7 +656,8 @@ export function LanguageServersPage() {
|
||||
if (!useTools.getState().updatesChecked) void checkToolUpdates();
|
||||
// Applied paths and servers change what is found and listed.
|
||||
return onIdeEvent("settingsChanged", (e) => {
|
||||
if (!e.key || /^(tools|languageServers)(\.|$)/.test(e.key)) void refreshTools();
|
||||
if (!e.key || /^(tools|languageServers|toolDownloads\.vueLanguageServerVersion)(\.|$)/.test(e.key))
|
||||
void refreshTools();
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -343,6 +343,33 @@ function ExecutableRow({ tool, pending }: { tool: ToolInfo; pending: boolean })
|
||||
);
|
||||
}
|
||||
|
||||
function VueVersionRow() {
|
||||
const form = useSettingsForm();
|
||||
const key = "toolDownloads.vueLanguageServerVersion";
|
||||
const version = form.useValue(key) as string | undefined;
|
||||
return (
|
||||
<Field<string>
|
||||
label="Vue Language Server version"
|
||||
value={version}
|
||||
format={(value) => value ?? ""}
|
||||
parse={(text) => {
|
||||
const value = text.trim();
|
||||
if (!value) return null;
|
||||
if (
|
||||
value === "latest" ||
|
||||
value === "3.0.x" ||
|
||||
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(value)
|
||||
)
|
||||
return value;
|
||||
throw new Error(tx("Enter latest, 3.0.x, or an exact Vue Language Server version."));
|
||||
}}
|
||||
onChange={(value) => form.set(key, value)}
|
||||
placeholder={tx("Auto-detect")}
|
||||
hint={<T>Auto uses 3.0.x for Vue 2 projects and the latest release for Vue 3.</T>}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Debug adapters: only where the executable is. */
|
||||
export function ToolSettings({ tool }: { tool: ToolInfo }) {
|
||||
return (
|
||||
@@ -383,6 +410,7 @@ export function ServerSettings({ tool, pending }: { tool: ToolInfo; pending: boo
|
||||
<div className={styles.form}>
|
||||
<Section title="Executable">
|
||||
<ExecutableRow tool={tool} pending={pending} />
|
||||
{tool.name === "vue-language-server" && <VueVersionRow />}
|
||||
{custom && (
|
||||
<>
|
||||
<Row label="Languages" htmlFor={languagesId}>
|
||||
|
||||
@@ -9700,5 +9700,8 @@
|
||||
"Remove from Solution '{name}'": "從方案 '{name}' 中移除",
|
||||
"Analyzers": "分析器",
|
||||
"The project was not added to the solution": "專案未加入方案",
|
||||
"The solution already contains a project with the same name as {names}.": "方案中已有與 {names} 同名的專案。"
|
||||
"The solution already contains a project with the same name as {names}.": "方案中已有與 {names} 同名的專案。",
|
||||
"Vue Language Server version": "Vue 語言伺服器版本",
|
||||
"Auto uses 3.0.x for Vue 2 projects and the latest release for Vue 3.": "自動選擇時,Vue 2 專案使用 3.0.x,Vue 3 專案使用最新版本。",
|
||||
"Enter latest, 3.0.x, or an exact Vue Language Server version.": "請輸入 latest、3.0.x 或 Vue 語言伺服器的確切版本。"
|
||||
}
|
||||
@@ -12031,5 +12031,8 @@
|
||||
"Analyzers": "分析器",
|
||||
"The project was not added to the solution": "项目未添加到解决方案",
|
||||
"The solution already contains a project with the same name as {names}.": "解决方案中已有与 {names} 同名的项目。",
|
||||
"Language server updates are available": "语言服务器有可用更新"
|
||||
"Language server updates are available": "语言服务器有可用更新",
|
||||
"Vue Language Server version": "Vue 语言服务器版本",
|
||||
"Auto uses 3.0.x for Vue 2 projects and the latest release for Vue 3.": "自动选择时,Vue 2 项目使用 3.0.x,Vue 3 项目使用最新版本。",
|
||||
"Enter latest, 3.0.x, or an exact Vue Language Server version.": "请输入 latest、3.0.x 或 Vue 语言服务器的具体版本。"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача