aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-24 07:07:39 +0000
committerBlaž Hrastnik2021-02-24 07:07:39 +0000
commit87a6d4e73615e17559b99afa065799a38fe6c39e (patch)
tree23e437304421ec88a355e3ef887cf6cb4a322591 /helix-lsp
parentc6456d04b9f16ed8f5ad0f256a38218b514de5dc (diff)
minor: Simplify some code.
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/client.rs26
-rw-r--r--helix-lsp/src/transport.rs7
2 files changed, 20 insertions, 13 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index b8b2971c..b229cd1a 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -255,11 +255,6 @@ impl Client {
.await
}
- // TODO: this is dumb. TextEdit describes changes to the initial doc (concurrent), but
- // TextDocumentContentChangeEvent describes a series of changes (sequential).
- // So S -> S1 -> S2, meaning positioning depends on the previous edits.
- //
- // Calculation is therefore a bunch trickier.
pub fn changeset_to_changes(
old_text: &Rope,
new_text: &Rope,
@@ -274,6 +269,12 @@ impl Client {
use crate::util::pos_to_lsp_pos;
use helix_core::Operation::*;
+ // this is dumb. TextEdit describes changes to the initial doc (concurrent), but
+ // TextDocumentContentChangeEvent describes a series of changes (sequential).
+ // So S -> S1 -> S2, meaning positioning depends on the previous edits.
+ //
+ // Calculation is therefore a bunch trickier.
+
// TODO: stolen from syntax.rs, share
use helix_core::RopeSlice;
fn traverse(pos: lsp::Position, text: RopeSlice) -> lsp::Position {
@@ -397,8 +398,6 @@ impl Client {
.await
}
- // TODO: impl into() TextDocumentIdentifier / VersionedTextDocumentIdentifier for Document.
-
pub async fn text_document_did_close(
&self,
text_document: lsp::TextDocumentIdentifier,
@@ -411,15 +410,22 @@ impl Client {
// will_save / will_save_wait_until
- pub async fn text_document_did_save(&self) -> anyhow::Result<()> {
- unimplemented!()
+ pub async fn text_document_did_save(
+ &self,
+ text_document: lsp::TextDocumentIdentifier,
+ ) -> Result<()> {
+ self.notify::<lsp::notification::DidSaveTextDocument>(lsp::DidSaveTextDocumentParams {
+ text_document,
+ text: None, // TODO:
+ })
+ .await
}
pub async fn completion(
&self,
text_document: lsp::TextDocumentIdentifier,
position: lsp::Position,
- ) -> anyhow::Result<Vec<lsp::CompletionItem>> {
+ ) -> Result<Vec<lsp::CompletionItem>> {
// TODO: figure out what should happen when you complete with multiple cursors
let params = lsp::CompletionParams {
diff --git a/helix-lsp/src/transport.rs b/helix-lsp/src/transport.rs
index 74ecde5e..ff1eedaf 100644
--- a/helix-lsp/src/transport.rs
+++ b/helix-lsp/src/transport.rs
@@ -1,4 +1,5 @@
use std::collections::HashMap;
+use std::io;
use log::{error, info};
@@ -128,7 +129,7 @@ impl Transport {
Ok(())
}
- pub async fn send_payload(&mut self, payload: Payload) -> anyhow::Result<()> {
+ pub async fn send_payload(&mut self, payload: Payload) -> io::Result<()> {
match payload {
Payload::Request { chan, value } => {
self.pending_requests.insert(value.id.clone(), chan);
@@ -147,7 +148,7 @@ impl Transport {
}
}
- pub async fn send(&mut self, request: String) -> anyhow::Result<()> {
+ pub async fn send(&mut self, request: String) -> io::Result<()> {
info!("-> {}", request);
// send the headers
@@ -174,7 +175,7 @@ impl Transport {
Ok(())
}
- async fn recv_response(&mut self, output: jsonrpc::Output) -> anyhow::Result<()> {
+ async fn recv_response(&mut self, output: jsonrpc::Output) -> io::Result<()> {
let (id, result) = match output {
jsonrpc::Output::Success(jsonrpc::Success { id, result, .. }) => {
info!("<- {}", result);