typescript: Add completions for tsconfig.json properties (#12560)
Release Notes: - Added completions for tsconfig.json config file.
This commit is contained in:
@@ -15,6 +15,7 @@ use std::{
|
|||||||
any::Any,
|
any::Any,
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
str::FromStr,
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
use task::{TaskTemplate, TaskTemplates, VariableName};
|
use task::{TaskTemplate, TaskTemplates, VariableName};
|
||||||
@@ -22,6 +23,8 @@ use util::{maybe, paths, ResultExt};
|
|||||||
|
|
||||||
const SERVER_PATH: &str = "node_modules/vscode-json-languageserver/bin/vscode-json-languageserver";
|
const SERVER_PATH: &str = "node_modules/vscode-json-languageserver/bin/vscode-json-languageserver";
|
||||||
|
|
||||||
|
// Origin: https://github.com/SchemaStore/schemastore
|
||||||
|
const TSCONFIG_SCHEMA: &str = include_str!("json/schemas/tsconfig.json");
|
||||||
pub(super) fn json_task_context() -> ContextProviderWithTasks {
|
pub(super) fn json_task_context() -> ContextProviderWithTasks {
|
||||||
ContextProviderWithTasks::new(TaskTemplates(vec![
|
ContextProviderWithTasks::new(TaskTemplates(vec![
|
||||||
TaskTemplate {
|
TaskTemplate {
|
||||||
@@ -74,6 +77,7 @@ impl JsonLspAdapter {
|
|||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
let tasks_schema = task::TaskTemplates::generate_json_schema();
|
let tasks_schema = task::TaskTemplates::generate_json_schema();
|
||||||
|
let tsconfig_schema = serde_json::Value::from_str(TSCONFIG_SCHEMA).unwrap();
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"json": {
|
"json": {
|
||||||
"format": {
|
"format": {
|
||||||
@@ -97,6 +101,10 @@ impl JsonLspAdapter {
|
|||||||
&*paths::LOCAL_TASKS_RELATIVE_PATH,
|
&*paths::LOCAL_TASKS_RELATIVE_PATH,
|
||||||
],
|
],
|
||||||
"schema": tasks_schema,
|
"schema": tasks_schema,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fileMatch": "*/tsconfig.json",
|
||||||
|
"schema":tsconfig_schema
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user