Skip to content

Commit

Permalink
Use lspservice build instead of new
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Nov 3, 2023
1 parent 862fe9a commit 62c036b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Server {
Self { args, inner: None }
}

fn attach_to(&mut self, client: Client) {
fn with_client(mut self, client: Client) -> Self {
let clients = Clients::new();
let documents = Arc::new(DashMap::new());

Expand All @@ -71,15 +71,12 @@ impl Server {
});

self.watch_rate_limit();
self
}

pub async fn serve(mut self) -> Result<()> {
// FUTURE: Add custom notifications here by using
// LspService::build and calling custom_method
let (service, socket) = LspService::new(|client| {
self.attach_to(client);
self
});
pub async fn serve(self) -> Result<()> {
// FUTURE: Add custom notifications here by calling custom_method
let (service, socket) = LspService::build(|client| self.with_client(client)).finish();

match service.inner().args.transport {
Transport::Socket(port) => {
Expand Down

0 comments on commit 62c036b

Please sign in to comment.