Enable formatting feature of JSON language server
The feature doesn't work yet because the JSON language server only supports *range* formatting, not document formatting. We need to adjust our code to inspect the server's capabilities and send range formatting requests instead when needed. We're going to hold off on doing this right now, because it will create merge conflicts with the `preserve-worktrees` branch (#525) Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
81627a0f14
commit
9999862016
3 changed files with 32 additions and 6 deletions
|
@ -18,6 +18,7 @@ use highlight_map::HighlightMap;
|
|||
use lazy_static::lazy_static;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
ops::Range,
|
||||
|
@ -78,9 +79,11 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
) -> BoxFuture<'static, Result<PathBuf>>;
|
||||
fn cached_server_binary(&self, container_dir: PathBuf) -> BoxFuture<'static, Option<PathBuf>>;
|
||||
fn process_diagnostics(&self, diagnostics: &mut lsp::PublishDiagnosticsParams);
|
||||
|
||||
fn label_for_completion(&self, _: &lsp::CompletionItem, _: &Language) -> Option<CodeLabel> {
|
||||
None
|
||||
}
|
||||
|
||||
fn label_for_symbol(&self, _: &str, _: lsp::SymbolKind, _: &Language) -> Option<CodeLabel> {
|
||||
None
|
||||
}
|
||||
|
@ -88,6 +91,10 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
fn server_args(&self) -> &[&str] {
|
||||
&[]
|
||||
}
|
||||
|
||||
fn initialization_options(&self) -> Option<Value> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -291,8 +298,13 @@ impl LanguageRegistry {
|
|||
Some(cx.background().spawn(async move {
|
||||
let server_binary_path = server_binary_path.await?;
|
||||
let server_args = adapter.server_args();
|
||||
let server =
|
||||
lsp::LanguageServer::new(&server_binary_path, server_args, &root_path, background)?;
|
||||
let server = lsp::LanguageServer::new(
|
||||
&server_binary_path,
|
||||
server_args,
|
||||
adapter.initialization_options(),
|
||||
&root_path,
|
||||
background,
|
||||
)?;
|
||||
Ok(server)
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue