mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Support formatting in fake LSP capabilities
This commit is contained in:
parent
46da80d726
commit
d8ef3a5d61
2 changed files with 10 additions and 2 deletions
|
@ -524,6 +524,8 @@ impl LanguageServer {
|
|||
ServerCapabilities {
|
||||
document_highlight_provider: Some(OneOf::Left(true)),
|
||||
code_action_provider: Some(CodeActionProviderCapability::Simple(true)),
|
||||
document_formatting_provider: Some(OneOf::Left(true)),
|
||||
document_range_formatting_provider: Some(OneOf::Left(true)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1323,7 +1323,10 @@ impl Project {
|
|||
let text_document = lsp::TextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(&buffer_abs_path).unwrap(),
|
||||
);
|
||||
let lsp_edits = if capabilities.document_formatting_provider.is_some() {
|
||||
let lsp_edits = if capabilities
|
||||
.document_formatting_provider
|
||||
.map_or(false, |provider| provider != lsp::OneOf::Left(false))
|
||||
{
|
||||
lang_server
|
||||
.request::<lsp::request::Formatting>(lsp::DocumentFormattingParams {
|
||||
text_document,
|
||||
|
@ -1331,7 +1334,10 @@ impl Project {
|
|||
work_done_progress_params: Default::default(),
|
||||
})
|
||||
.await?
|
||||
} else if capabilities.document_range_formatting_provider.is_some() {
|
||||
} else if capabilities
|
||||
.document_range_formatting_provider
|
||||
.map_or(false, |provider| provider != lsp::OneOf::Left(false))
|
||||
{
|
||||
let buffer_start = lsp::Position::new(0, 0);
|
||||
let buffer_end = buffer
|
||||
.read_with(&cx, |buffer, _| buffer.max_point_utf16())
|
||||
|
|
Loading…
Reference in a new issue