Hard-code LSP formatting options for now

This is needed for auto-formatting to work properly in TypeScript and JSON

Co-Authored-By: Keith Simmons <keith@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-03-30 17:08:40 -07:00
parent cf9efd7005
commit c280c85ce7
2 changed files with 14 additions and 2 deletions

View file

@ -181,6 +181,7 @@ impl LanguageServer {
buffer.resize(message_len, 0);
stdout.read_exact(&mut buffer).await?;
log::trace!("incoming message:{}", String::from_utf8_lossy(&buffer));
if let Ok(AnyNotification { id, method, params }) =
serde_json::from_slice(&buffer)
@ -229,6 +230,7 @@ impl LanguageServer {
let _clear_response_handlers = ClearResponseHandlers(response_handlers);
let mut content_len_buffer = Vec::new();
while let Ok(message) = outbound_rx.recv().await {
log::trace!("outgoing message:{}", String::from_utf8_lossy(&message));
content_len_buffer.clear();
write!(content_len_buffer, "{}", message.len()).unwrap();
stdin.write_all(CONTENT_LEN_HEADER.as_bytes()).await?;

View file

@ -2046,7 +2046,12 @@ impl Project {
language_server
.request::<lsp::request::Formatting>(lsp::DocumentFormattingParams {
text_document,
options: Default::default(),
options: lsp::FormattingOptions {
tab_size: 4,
insert_spaces: true,
insert_final_newline: Some(true),
..Default::default()
},
work_done_progress_params: Default::default(),
})
.await?
@ -2064,7 +2069,12 @@ impl Project {
lsp::DocumentRangeFormattingParams {
text_document,
range: lsp::Range::new(buffer_start, buffer_end),
options: Default::default(),
options: lsp::FormattingOptions {
tab_size: 4,
insert_spaces: true,
insert_final_newline: Some(true),
..Default::default()
},
work_done_progress_params: Default::default(),
},
)