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 {
|
ServerCapabilities {
|
||||||
document_highlight_provider: Some(OneOf::Left(true)),
|
document_highlight_provider: Some(OneOf::Left(true)),
|
||||||
code_action_provider: Some(CodeActionProviderCapability::Simple(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()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1323,7 +1323,10 @@ impl Project {
|
||||||
let text_document = lsp::TextDocumentIdentifier::new(
|
let text_document = lsp::TextDocumentIdentifier::new(
|
||||||
lsp::Url::from_file_path(&buffer_abs_path).unwrap(),
|
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
|
lang_server
|
||||||
.request::<lsp::request::Formatting>(lsp::DocumentFormattingParams {
|
.request::<lsp::request::Formatting>(lsp::DocumentFormattingParams {
|
||||||
text_document,
|
text_document,
|
||||||
|
@ -1331,7 +1334,10 @@ impl Project {
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
})
|
})
|
||||||
.await?
|
.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_start = lsp::Position::new(0, 0);
|
||||||
let buffer_end = buffer
|
let buffer_end = buffer
|
||||||
.read_with(&cx, |buffer, _| buffer.max_point_utf16())
|
.read_with(&cx, |buffer, _| buffer.max_point_utf16())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue