Add setting for removing trailing whitespace on save

This commit is contained in:
Max Brunsfeld 2023-02-27 12:14:18 -08:00
parent b00e467ede
commit ff85bc6d42
8 changed files with 231 additions and 53 deletions

View file

@ -422,6 +422,10 @@ impl LanguageServer {
self.notification_handlers.lock().remove(T::METHOD);
}
pub fn remove_notification_handler<T: notification::Notification>(&self) {
self.notification_handlers.lock().remove(T::METHOD);
}
#[must_use]
pub fn on_custom_notification<Params, F>(&self, method: &'static str, mut f: F) -> Subscription
where
@ -780,6 +784,26 @@ impl FakeLanguageServer {
responded_rx
}
pub fn handle_notification<T, F>(
&self,
mut handler: F,
) -> futures::channel::mpsc::UnboundedReceiver<()>
where
T: 'static + notification::Notification,
T::Params: 'static + Send,
F: 'static + Send + FnMut(T::Params, gpui::AsyncAppContext),
{
let (handled_tx, handled_rx) = futures::channel::mpsc::unbounded();
self.server.remove_notification_handler::<T>();
self.server
.on_notification::<T, _>(move |params, cx| {
handler(params, cx.clone());
handled_tx.unbounded_send(()).ok();
})
.detach();
handled_rx
}
pub fn remove_request_handler<T>(&mut self)
where
T: 'static + request::Request,