/** * Settings › Languages & Frameworks › Go / Java / Node.js / PHP / Rust / TypeScript and * Build Tools › Maven: the toolchain each language's server and run configurations * use (applied by `ide-sdk` when language servers start and when run configurations load). */ import { useId, useMemo } from "react"; import { IconButton, Input, type SelectOption } from "@/ui"; import { Row, Section, Select, Toggle } from "../components/Form"; import { choosePath } from "./api"; import { useSetting } from "../components/context"; import { SdkField, tildify, useDetected } from "./components"; import styles from "./Sdk.module.css"; function PathInput({ k, label, placeholder, hint, title, file, }: { k: string; label: string; placeholder: string; hint?: string; title: string; /** Browse for a file instead of a directory. */ file?: boolean; }) { const [value, set] = useSetting(k); const id = useId(); return ( set(e.target.value.trim())} /> { const p = await choosePath({ directory: !file, title, defaultPath: value || undefined }); if (p) set(p); }} /> ); } function SdkRow({ k, label, hint, ...field }: { k: string; label: string; hint?: string } & Omit[0], "value" | "onChange">) { const [value, set] = useSetting(k); return ( ); } // --------------------------------------------------------------------------- // Node.js export function NodePage() { const [pm, setPm] = useSetting("languages.node.packageManager"); const { list } = useDetected("packageManager"); const pmOptions = useMemo( () => [ { value: "", label: "Auto", detail: "from packageManager / lock file" }, ...(["npm", "pnpm", "yarn", "bun"] as const).map((name) => { const found = list.find((s) => s.name === name); return { value: name, label: name, detail: found ? `${found.version ?? ""} ${tildify(found.path)}`.trim() : "not found", }; }), ], [list], ); return (
setRustfmtArgs(e.target.value)} />
); } // --------------------------------------------------------------------------- // Go export function GoPage() { const { list } = useDetected("go"); const defaultGopath = list.find((s) => s.extra)?.extra; return (
); } // --------------------------------------------------------------------------- // Java export function JavaPage() { const [vmArgs, setVmArgs] = useSetting("languages.java.jdtlsVmArgs"); const id = useId(); return (
setVmArgs(e.target.value)} />
); } // --------------------------------------------------------------------------- // Build Tools › Gradle / Maven export function GradlePage() { const [distribution, setDistribution] = useSetting("languages.java.gradle.distribution"); return (
{ const p = await choosePath({ directory: true, title: "Select TypeScript lib Directory" }); if (p) setVersion(p); }} />
); }