Add local next LSP adapter

This commit is contained in:
Mikayla 2023-09-21 18:06:00 -07:00
parent 0cceb3fdf1
commit 02a85b1252
No known key found for this signature in database
5 changed files with 206 additions and 12 deletions

View file

@ -2267,11 +2267,13 @@ impl Project {
};
for (_, _, server) in self.language_servers_for_worktree(worktree_id) {
let text = include_text(server.as_ref()).then(|| buffer.read(cx).text());
server
.notify::<lsp::notification::DidSaveTextDocument>(
lsp::DidSaveTextDocumentParams {
text_document: text_document.clone(),
text: None,
text,
},
)
.log_err();
@ -8274,3 +8276,19 @@ async fn wait_for_loading_buffer(
receiver.next().await;
}
}
fn include_text(server: &lsp::LanguageServer) -> bool {
server
.capabilities()
.text_document_sync
.as_ref()
.and_then(|sync| match sync {
lsp::TextDocumentSyncCapability::Kind(_) => None,
lsp::TextDocumentSyncCapability::Options(options) => options.save.as_ref(),
})
.and_then(|save_options| match save_options {
lsp::TextDocumentSyncSaveOptions::Supported(_) => None,
lsp::TextDocumentSyncSaveOptions::SaveOptions(options) => options.include_text,
})
.unwrap_or(false)
}