mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-16 17:07:14 +03:00
Fix Prettier parser values when formatting files with paths (#13666)
Closes https://github.com/zed-industries/zed/issues/13660 Now, as intended, the parser value is passed only if configured in the language settings. Also, allows to format JSONC by default with Prettier and reformats Zed settings. Release Notes: - Fixed Zed Prettier integration always passing parser value for files with paths ([13660](https://github.com/zed-industries/zed/issues/13660))
This commit is contained in:
parent
f1859e3645
commit
e650c0166d
@ -8,7 +8,7 @@
|
|||||||
"theme": {
|
"theme": {
|
||||||
"mode": "system",
|
"mode": "system",
|
||||||
"light": "One Light",
|
"light": "One Light",
|
||||||
"dark": "One Dark",
|
"dark": "One Dark"
|
||||||
},
|
},
|
||||||
// The name of a base set of key bindings to use.
|
// The name of a base set of key bindings to use.
|
||||||
// This setting can take four values, each named after another
|
// This setting can take four values, each named after another
|
||||||
@ -128,14 +128,7 @@
|
|||||||
// The default number of lines to expand excerpts in the multibuffer by.
|
// The default number of lines to expand excerpts in the multibuffer by.
|
||||||
"expand_excerpt_lines": 3,
|
"expand_excerpt_lines": 3,
|
||||||
// Globs to match against file paths to determine if a file is private.
|
// Globs to match against file paths to determine if a file is private.
|
||||||
"private_files": [
|
"private_files": ["**/.env*", "**/*.pem", "**/*.key", "**/*.cert", "**/*.crt", "**/secrets.yml"],
|
||||||
"**/.env*",
|
|
||||||
"**/*.pem",
|
|
||||||
"**/*.key",
|
|
||||||
"**/*.cert",
|
|
||||||
"**/*.crt",
|
|
||||||
"**/secrets.yml"
|
|
||||||
],
|
|
||||||
// Whether to use additional LSP queries to format (and amend) the code after
|
// Whether to use additional LSP queries to format (and amend) the code after
|
||||||
// every "trigger" symbol input, defined by LSP server capabilities.
|
// every "trigger" symbol input, defined by LSP server capabilities.
|
||||||
"use_on_type_format": true,
|
"use_on_type_format": true,
|
||||||
@ -406,9 +399,7 @@
|
|||||||
// The list of language servers to use (or disable) for all languages.
|
// The list of language servers to use (or disable) for all languages.
|
||||||
//
|
//
|
||||||
// This is typically customized on a per-language basis.
|
// This is typically customized on a per-language basis.
|
||||||
"language_servers": [
|
"language_servers": ["..."],
|
||||||
"..."
|
|
||||||
],
|
|
||||||
// When to automatically save edited buffers. This setting can
|
// When to automatically save edited buffers. This setting can
|
||||||
// take four values.
|
// take four values.
|
||||||
//
|
//
|
||||||
@ -543,9 +534,7 @@
|
|||||||
},
|
},
|
||||||
"inline_completions": {
|
"inline_completions": {
|
||||||
// A list of globs representing files that inline completions should be disabled for.
|
// A list of globs representing files that inline completions should be disabled for.
|
||||||
"disabled_globs": [
|
"disabled_globs": [".env"]
|
||||||
".env"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
// Settings specific to journaling
|
// Settings specific to journaling
|
||||||
"journal": {
|
"journal": {
|
||||||
@ -656,12 +645,7 @@
|
|||||||
// Default directories to search for virtual environments, relative
|
// Default directories to search for virtual environments, relative
|
||||||
// to the current working directory. We recommend overriding this
|
// to the current working directory. We recommend overriding this
|
||||||
// in your project's settings, rather than globally.
|
// in your project's settings, rather than globally.
|
||||||
"directories": [
|
"directories": [".env", "env", ".venv", "venv"],
|
||||||
".env",
|
|
||||||
"env",
|
|
||||||
".venv",
|
|
||||||
"venv"
|
|
||||||
],
|
|
||||||
// Can also be `csh`, `fish`, and `nushell`
|
// Can also be `csh`, `fish`, and `nushell`
|
||||||
"activate_script": "default"
|
"activate_script": "default"
|
||||||
}
|
}
|
||||||
@ -695,10 +679,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
"file_types": {
|
"file_types": {
|
||||||
"JSONC": [
|
"JSONC": ["**/.zed/**/*.json", "**/zed/**/*.json"]
|
||||||
"**/.zed/**/*.json",
|
|
||||||
"**/zed/**/*.json"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
// The extensions that Zed should automatically install on startup.
|
// The extensions that Zed should automatically install on startup.
|
||||||
//
|
//
|
||||||
@ -712,9 +693,7 @@
|
|||||||
"Astro": {
|
"Astro": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["prettier-plugin-astro"]
|
||||||
"prettier-plugin-astro"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Blade": {
|
"Blade": {
|
||||||
@ -734,12 +713,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Elixir": {
|
"Elixir": {
|
||||||
"language_servers": [
|
"language_servers": ["elixir-ls", "!next-ls", "!lexical", "..."]
|
||||||
"elixir-ls",
|
|
||||||
"!next-ls",
|
|
||||||
"!lexical",
|
|
||||||
"..."
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"Go": {
|
"Go": {
|
||||||
"code_actions_on_format": {
|
"code_actions_on_format": {
|
||||||
@ -752,12 +726,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"HEEX": {
|
"HEEX": {
|
||||||
"language_servers": [
|
"language_servers": ["elixir-ls", "!next-ls", "!lexical", "..."]
|
||||||
"elixir-ls",
|
|
||||||
"!next-ls",
|
|
||||||
"!lexical",
|
|
||||||
"..."
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"HTML": {
|
"HTML": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
@ -767,17 +736,11 @@
|
|||||||
"Java": {
|
"Java": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["prettier-plugin-java"]
|
||||||
"prettier-plugin-java"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"JavaScript": {
|
"JavaScript": {
|
||||||
"language_servers": [
|
"language_servers": ["!typescript-language-server", "vtsls", "..."],
|
||||||
"!typescript-language-server",
|
|
||||||
"vtsls",
|
|
||||||
"..."
|
|
||||||
],
|
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true
|
"allowed": true
|
||||||
}
|
}
|
||||||
@ -787,6 +750,11 @@
|
|||||||
"allowed": true
|
"allowed": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"JSONC": {
|
||||||
|
"prettier": {
|
||||||
|
"allowed": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"Markdown": {
|
"Markdown": {
|
||||||
"format_on_save": "off",
|
"format_on_save": "off",
|
||||||
"prettier": {
|
"prettier": {
|
||||||
@ -796,17 +764,11 @@
|
|||||||
"PHP": {
|
"PHP": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["@prettier/plugin-php"]
|
||||||
"@prettier/plugin-php"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Ruby": {
|
"Ruby": {
|
||||||
"language_servers": [
|
"language_servers": ["solargraph", "!ruby-lsp", "..."]
|
||||||
"solargraph",
|
|
||||||
"!ruby-lsp",
|
|
||||||
"..."
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"SCSS": {
|
"SCSS": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
@ -816,25 +778,17 @@
|
|||||||
"SQL": {
|
"SQL": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["prettier-plugin-sql"]
|
||||||
"prettier-plugin-sql"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Svelte": {
|
"Svelte": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["prettier-plugin-svelte"]
|
||||||
"prettier-plugin-svelte"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TSX": {
|
"TSX": {
|
||||||
"language_servers": [
|
"language_servers": ["!typescript-language-server", "vtsls", "..."],
|
||||||
"!typescript-language-server",
|
|
||||||
"vtsls",
|
|
||||||
"..."
|
|
||||||
],
|
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true
|
"allowed": true
|
||||||
}
|
}
|
||||||
@ -845,11 +799,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TypeScript": {
|
"TypeScript": {
|
||||||
"language_servers": [
|
"language_servers": ["!typescript-language-server", "vtsls", "..."],
|
||||||
"!typescript-language-server",
|
|
||||||
"vtsls",
|
|
||||||
"..."
|
|
||||||
],
|
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true
|
"allowed": true
|
||||||
}
|
}
|
||||||
@ -862,9 +812,7 @@
|
|||||||
"XML": {
|
"XML": {
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"allowed": true,
|
"allowed": true,
|
||||||
"plugins": [
|
"plugins": ["@prettier/plugin-xml"]
|
||||||
"@prettier/plugin-xml"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"YAML": {
|
"YAML": {
|
||||||
|
@ -317,11 +317,14 @@ impl Prettier {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let prettier_parser = prettier_settings.parser.as_deref().or_else(|| buffer_language.and_then(|language| language.prettier_parser_name()));
|
let mut prettier_parser = prettier_settings.parser.as_deref();
|
||||||
|
if buffer_path.is_none() {
|
||||||
|
prettier_parser = prettier_parser.or_else(|| buffer_language.and_then(|language| language.prettier_parser_name()));
|
||||||
|
if prettier_parser.is_none() {
|
||||||
|
log::error!("Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}");
|
||||||
|
return Err(anyhow!("Cannot determine prettier parser for unsaved file"));
|
||||||
|
}
|
||||||
|
|
||||||
if prettier_parser.is_none() && buffer_path.is_none() {
|
|
||||||
log::error!("Formatting unsaved file with prettier failed. No prettier parser configured for language {buffer_language:?}");
|
|
||||||
return Err(anyhow!("Cannot determine prettier parser for unsaved file"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!(
|
log::debug!(
|
||||||
|
Loading…
Reference in New Issue
Block a user