Add auto-completion support for package.json files (#12792)

![截屏2024-06-08 07 56
41](https://github.com/zed-industries/zed/assets/21101490/da97e7d4-458b-4262-ac23-a4704af4f015)

Release Notes:

- Added auto-completion support for `package.json` files.
This commit is contained in:
Panghu 2024-06-08 19:33:29 +09:00 committed by GitHub
parent 87845a349d
commit e829a8c3b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 872 additions and 0 deletions

View file

@ -25,6 +25,8 @@ const SERVER_PATH: &str = "node_modules/vscode-json-languageserver/bin/vscode-js
// Origin: https://github.com/SchemaStore/schemastore
const TSCONFIG_SCHEMA: &str = include_str!("json/schemas/tsconfig.json");
const PACKAGE_JSON_SCHEMA: &str = include_str!("json/schemas/package.json");
pub(super) fn json_task_context() -> ContextProviderWithTasks {
ContextProviderWithTasks::new(TaskTemplates(vec![
TaskTemplate {
@ -78,6 +80,8 @@ impl JsonLspAdapter {
);
let tasks_schema = task::TaskTemplates::generate_json_schema();
let tsconfig_schema = serde_json::Value::from_str(TSCONFIG_SCHEMA).unwrap();
let package_json_schema = serde_json::Value::from_str(PACKAGE_JSON_SCHEMA).unwrap();
serde_json::json!({
"json": {
"format": {
@ -88,6 +92,10 @@ impl JsonLspAdapter {
"fileMatch": ["tsconfig.json"],
"schema":tsconfig_schema
},
{
"fileMatch": ["package.json"],
"schema":package_json_schema
},
{
"fileMatch": [
schema_file_match(&paths::SETTINGS),