Specify a schema to use when dealing with JSONC files (#44250)
Follow-up of https://github.com/zed-industries/zed/pull/43854 Closes https://github.com/zed-industries/zed/issues/40970 Seems that json language server does not distinguish between JSONC and JSON files in runtime, but there is a static schema, which accepts globs in its `fileMatch` fields. Use all glob overrides and file suffixes for JSONC inside those match fields, and provide a grammar for such matches, which accepts trailing commas. Release Notes: - Improved JSONC trailing comma handling
This commit is contained in:
@@ -7,8 +7,8 @@ use futures::StreamExt;
|
||||
use gpui::{App, AsyncApp, Task};
|
||||
use http_client::github::{GitHubLspBinaryVersion, latest_github_release};
|
||||
use language::{
|
||||
ContextProvider, LanguageName, LocalFile as _, LspAdapter, LspAdapterDelegate, LspInstaller,
|
||||
Toolchain,
|
||||
ContextProvider, LanguageName, LanguageRegistry, LocalFile as _, LspAdapter,
|
||||
LspAdapterDelegate, LspInstaller, Toolchain,
|
||||
};
|
||||
use lsp::{LanguageServerBinary, LanguageServerName, Uri};
|
||||
use node_runtime::{NodeRuntime, VersionStrategy};
|
||||
@@ -129,14 +129,15 @@ fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||
}
|
||||
|
||||
pub struct JsonLspAdapter {
|
||||
languages: Arc<LanguageRegistry>,
|
||||
node: NodeRuntime,
|
||||
}
|
||||
|
||||
impl JsonLspAdapter {
|
||||
const PACKAGE_NAME: &str = "vscode-langservers-extracted";
|
||||
|
||||
pub fn new(node: NodeRuntime) -> Self {
|
||||
Self { node }
|
||||
pub fn new(languages: Arc<LanguageRegistry>, node: NodeRuntime) -> Self {
|
||||
Self { languages, node }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +256,7 @@ impl LspAdapter for JsonLspAdapter {
|
||||
cx: &mut AsyncApp,
|
||||
) -> Result<Value> {
|
||||
let mut config = cx.update(|cx| {
|
||||
let schemas = json_schema_store::all_schema_file_associations(cx);
|
||||
let schemas = json_schema_store::all_schema_file_associations(&self.languages, cx);
|
||||
|
||||
// This can be viewed via `dev: open language server logs` -> `json-language-server` ->
|
||||
// `Server Info`
|
||||
|
||||
@@ -89,7 +89,7 @@ pub fn init(languages: Arc<LanguageRegistry>, fs: Arc<dyn Fs>, node: NodeRuntime
|
||||
let go_context_provider = Arc::new(go::GoContextProvider);
|
||||
let go_lsp_adapter = Arc::new(go::GoLspAdapter);
|
||||
let json_context_provider = Arc::new(JsonTaskProvider);
|
||||
let json_lsp_adapter = Arc::new(json::JsonLspAdapter::new(node.clone()));
|
||||
let json_lsp_adapter = Arc::new(json::JsonLspAdapter::new(languages.clone(), node.clone()));
|
||||
let node_version_lsp_adapter = Arc::new(json::NodeVersionAdapter);
|
||||
let py_lsp_adapter = Arc::new(python::PyLspAdapter::new());
|
||||
let ty_lsp_adapter = Arc::new(python::TyLspAdapter::new(fs.clone()));
|
||||
|
||||
Reference in New Issue
Block a user