Reformat Code only asked the language server for formatting, so files whose server has no formatting capability (Markdown with marksman, and others depending on the server) could not be formatted. Languages can now declare an external formatter. Prettier is the first: a managed tool installed on demand, or the project's own node_modules/prettier, an explicit path, or PATH. It runs on the backend copy of the document with the file's path so Prettier resolves the project's config, overrides and ignore files, and its result is applied as one undoable edit. Language servers that format a file keep doing so unless Prettier is preferred in Settings › Languages › Prettier; formatting on save is opt-in. Parsers without range support format the whole file and say so. Errors carry structured tool data, so a missing Prettier reuses the shared install prompt and Prettier diagnostics or timeouts show as non-sticky notifications. Fixes #639
151 lines
3.9 KiB
TypeScript
151 lines
3.9 KiB
TypeScript
/**
|
||
* PyCharm's top-level "Python" group (Interpreter), "Project Structure", and
|
||
* Languages & Frameworks › Go / Java / Node.js / Rust / TypeScript. Pages live in
|
||
* `../languages/`; settings are `languages.*` / `projectStructure.*`.
|
||
*/
|
||
import { GoPage, JavaPage, NodePage, RustPage, TypeScriptPage } from "../languages/LanguagePages";
|
||
import { PrettierPage } from "../languages/PrettierPage";
|
||
import { ProjectStructurePage } from "../languages/ProjectStructurePage";
|
||
import { PythonInterpreterPage } from "../languages/PythonInterpreterPage";
|
||
import { GoBuildTagsPage, GO_BUILD_TAG_SECTIONS } from "../languages/GoBuildTags";
|
||
import { GoModulesPage, GO_MODULE_SECTIONS } from "../languages/GoModules";
|
||
import type { PageSpec } from "./spec";
|
||
|
||
export const LANGUAGES_GROUP = "Languages & Frameworks";
|
||
|
||
export const LANGUAGE_PAGES: PageSpec[] = [
|
||
{
|
||
id: "python.interpreter",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Python Interpreter",
|
||
group: LANGUAGES_GROUP,
|
||
order: 403,
|
||
keywords: [
|
||
"python interpreter",
|
||
"sdk",
|
||
"virtualenv",
|
||
"venv",
|
||
"conda",
|
||
"pyenv",
|
||
"packages",
|
||
"pip",
|
||
"install package",
|
||
"add interpreter",
|
||
"activate virtualenv",
|
||
],
|
||
component: PythonInterpreterPage,
|
||
},
|
||
{
|
||
id: "projectStructure",
|
||
title: "Project Structure",
|
||
// IntelliJ IDEA order: … Version Control, Project Structure, Build, Execution, Deployment, Languages & Frameworks …
|
||
order: 350,
|
||
keywords: ["content root", "sources root", "test sources", "resources", "excluded", "mark directory as"],
|
||
component: ProjectStructurePage,
|
||
},
|
||
{
|
||
id: "languages.go",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Go",
|
||
group: LANGUAGES_GROUP,
|
||
order: 390,
|
||
keywords: ["goroot", "gopath", "go sdk", "gopls"],
|
||
component: GoPage,
|
||
},
|
||
{
|
||
id: "languages.go.buildTags",
|
||
title: "Build Tags",
|
||
group: LANGUAGES_GROUP,
|
||
order: 391,
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
ownScopeSwitch: true,
|
||
sections: GO_BUILD_TAG_SECTIONS,
|
||
component: GoBuildTagsPage,
|
||
},
|
||
{
|
||
id: "languages.go.modules",
|
||
title: "Go Modules",
|
||
group: LANGUAGES_GROUP,
|
||
order: 392,
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
ownScopeSwitch: true,
|
||
sections: GO_MODULE_SECTIONS,
|
||
component: GoModulesPage,
|
||
},
|
||
{
|
||
id: "languages.java",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Java",
|
||
group: LANGUAGES_GROUP,
|
||
order: 395,
|
||
keywords: [
|
||
"jdk",
|
||
"project sdk",
|
||
"java home",
|
||
"jdtls",
|
||
"language server jdk",
|
||
"jdk for importer",
|
||
"jvm options",
|
||
"vmargs",
|
||
"lombok",
|
||
"javaagent",
|
||
"eclipse jdt",
|
||
],
|
||
component: JavaPage,
|
||
},
|
||
{
|
||
id: "languages.node",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Node.js",
|
||
group: LANGUAGES_GROUP,
|
||
order: 402,
|
||
keywords: ["node interpreter", "package manager", "npm", "pnpm", "yarn", "bun", "nvm"],
|
||
component: NodePage,
|
||
},
|
||
{
|
||
id: "languages.prettier",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Prettier",
|
||
group: LANGUAGES_GROUP,
|
||
order: 403.5,
|
||
keywords: ["formatter", "prettier", "markdown", "yaml", "css", "format on save", "node_modules"],
|
||
component: PrettierPage,
|
||
},
|
||
{
|
||
id: "languages.rust",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "Rust",
|
||
group: LANGUAGES_GROUP,
|
||
order: 404,
|
||
keywords: [
|
||
"toolchain",
|
||
"rustup",
|
||
"standard library",
|
||
"external linter",
|
||
"clippy",
|
||
"cargo check",
|
||
"rustfmt",
|
||
"rust-analyzer",
|
||
],
|
||
component: RustPage,
|
||
},
|
||
{
|
||
id: "languages.typescript",
|
||
projectScope: true,
|
||
defaultScope: "project",
|
||
title: "TypeScript",
|
||
group: LANGUAGES_GROUP,
|
||
order: 405,
|
||
keywords: ["typescript version", "tsdk", "tsserver", "node_modules", "vtsls"],
|
||
component: TypeScriptPage,
|
||
},
|
||
];
|