aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-22 05:35:07 +0000
committerBlaž Hrastnik2020-12-03 04:10:35 +0000
commitb39849dde1b1277d14dbc4e2e1604e5d020db43d (patch)
treec247d4f605db00248eaa0a4383c5ec65db5f69cc /helix-lsp
parent81ccca0c6a18de86223b8142b5742e0603b9b230 (diff)
Refactor: Document type as a wrapper around barebones State.
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/Cargo.toml1
-rw-r--r--helix-lsp/src/client.rs21
2 files changed, 12 insertions, 10 deletions
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index e4956f0b..351c3b0e 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -8,6 +8,7 @@ edition = "2018"
[dependencies]
helix-core = { path = "../helix-core" }
+helix-view = { path = "../helix-view" }
lsp-types = { version = "0.82", features = ["proposed"] }
smol = "1.2"
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 93e137cb..56413768 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -6,6 +6,7 @@ use crate::{
type Result<T> = core::result::Result<T, Error>;
use helix_core::{State, Transaction};
+use helix_view::Document;
// use std::collections::HashMap;
@@ -190,13 +191,13 @@ impl Client {
// Text document
// -------------------------------------------------------------------------------------------
- pub async fn text_document_did_open(&mut self, state: &State) -> Result<()> {
+ pub async fn text_document_did_open(&mut self, doc: &Document) -> Result<()> {
self.notify::<lsp::notification::DidOpenTextDocument>(lsp::DidOpenTextDocumentParams {
text_document: lsp::TextDocumentItem {
- uri: lsp::Url::from_file_path(state.path().unwrap()).unwrap(),
+ uri: lsp::Url::from_file_path(doc.path().unwrap()).unwrap(),
language_id: "rust".to_string(), // TODO: hardcoded for now
- version: state.version,
- text: String::from(&state.doc),
+ version: doc.version,
+ text: String::from(doc.text()),
},
})
.await
@@ -205,13 +206,13 @@ impl Client {
// TODO: trigger any time history.commit_revision happens
pub async fn text_document_did_change(
&mut self,
- state: &State,
+ doc: &Document,
transaction: &Transaction,
) -> Result<()> {
self.notify::<lsp::notification::DidChangeTextDocument>(lsp::DidChangeTextDocumentParams {
text_document: lsp::VersionedTextDocumentIdentifier::new(
- lsp::Url::from_file_path(state.path().unwrap()).unwrap(),
- state.version,
+ lsp::Url::from_file_path(doc.path().unwrap()).unwrap(),
+ doc.version,
),
content_changes: vec![lsp::TextDocumentContentChangeEvent {
// range = None -> whole document
@@ -223,12 +224,12 @@ impl Client {
.await
}
- // TODO: impl into() TextDocumentIdentifier / VersionedTextDocumentIdentifier for State.
+ // TODO: impl into() TextDocumentIdentifier / VersionedTextDocumentIdentifier for Document.
- pub async fn text_document_did_close(&mut self, state: &State) -> Result<()> {
+ pub async fn text_document_did_close(&mut self, doc: &Document) -> Result<()> {
self.notify::<lsp::notification::DidCloseTextDocument>(lsp::DidCloseTextDocumentParams {
text_document: lsp::TextDocumentIdentifier::new(
- lsp::Url::from_file_path(state.path().unwrap()).unwrap(),
+ lsp::Url::from_file_path(doc.path().unwrap()).unwrap(),
),
})
.await