Skip to content

Commit

Permalink
Add auto-completion support for package.json files (#12792)
Browse files Browse the repository at this point in the history
![截屏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.
  • Loading branch information
panghu-huang committed Jun 8, 2024
1 parent 87845a3 commit e829a8c
Show file tree
Hide file tree
Showing 2 changed files with 872 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/languages/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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": {
Expand All @@ -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),
Expand Down
Loading

0 comments on commit e829a8c

Please sign in to comment.