aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock84
-rw-r--r--helix-lsp/Cargo.toml2
-rw-r--r--helix-lsp/src/client.rs28
-rw-r--r--helix-term/src/application.rs23
-rw-r--r--helix-view/src/commands.rs2
5 files changed, 72 insertions, 67 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bc3da508..28fc503c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -29,9 +29,9 @@ checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
+checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "async-channel"
@@ -118,7 +118,7 @@ checksum = "4c8cea09c1fb10a317d1b5af8024eeba256d6554763e85ecd90ff8df31c7bbda"
dependencies = [
"async-io",
"blocking",
- "cfg-if",
+ "cfg-if 0.1.10",
"event-listener",
"futures-lite",
"once_cell",
@@ -209,6 +209,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -267,15 +273,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
- "cfg-if",
+ "cfg-if 0.1.10",
"lazy_static",
]
[[package]]
name = "crossterm"
-version = "0.18.0"
+version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2fcdc3c9cf8ee446222e8ee8691a6d21b563b8fe1a64b1873080db7b5b23cf0"
+checksum = "cef9149b29071d44c9fb98fd9c27fcf74405bbdb761889ad6a03f36be93b0b15"
dependencies = [
"bitflags",
"crossterm_winapi",
@@ -290,9 +296,9 @@ dependencies = [
[[package]]
name = "crossterm_winapi"
-version = "0.6.1"
+version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "057b7146d02fb50175fd7dbe5158f6097f33d02831f43b4ee8ae4ddf67b68f5c"
+checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db"
dependencies = [
"winapi",
]
@@ -303,7 +309,7 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"dirs-sys",
]
@@ -360,15 +366,15 @@ checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed"
[[package]]
name = "futures-core"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b"
+checksum = "18eaa56102984bed2c88ea39026cff3ce3b4c7f508ca970cedf2450ea10d4e46"
[[package]]
name = "futures-io"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fc94b64bb39543b4e432f1790b6bf18e3ee3b74653c5449f63310e9a74b123c"
+checksum = "6e1798854a4727ff944a7b12aa999f58ce7aa81db80d2dfaaf2ba06f065ddd2b"
[[package]]
name = "futures-lite"
@@ -387,9 +393,9 @@ dependencies = [
[[package]]
name = "futures-macro"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f57ed14da4603b2554682e9f2ff3c65d7567b53188db96cb71538217fc64581b"
+checksum = "e36fccf3fc58563b4a14d265027c627c3b665d7fed489427e88e7cc929559efe"
dependencies = [
"proc-macro-hack",
"proc-macro2",
@@ -399,18 +405,18 @@ dependencies = [
[[package]]
name = "futures-task"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4dd26820a9f3637f1302da8bceba3ff33adbe53464b54ca24d4e2d4f1db30f94"
+checksum = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c"
dependencies = [
"once_cell",
]
[[package]]
name = "futures-util"
-version = "0.3.6"
+version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34"
+checksum = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34"
dependencies = [
"futures-core",
"futures-macro",
@@ -428,7 +434,7 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
@@ -553,11 +559,11 @@ dependencies = [
[[package]]
name = "instant"
-version = "0.1.7"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66"
+checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
]
[[package]]
@@ -596,9 +602,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.79"
+version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
+checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
[[package]]
name = "lock_api"
@@ -615,14 +621,14 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
]
[[package]]
name = "lsp-types"
-version = "0.82.0"
+version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db895abb8527cf59e3de893ab2acf52cf904faeb65e60ea6f373e11fe86464e8"
+checksum = "25e0bd4b95038f2c23bda332ba0ca684e8dda765db1f9bdb63dc4c3e01f3b456"
dependencies = [
"base64",
"bitflags",
@@ -691,9 +697,9 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "ntapi"
-version = "0.3.4"
+version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2"
+checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
]
@@ -762,7 +768,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"cloudabi",
"instant",
"libc",
@@ -785,18 +791,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pin-project"
-version = "0.4.27"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15"
+checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
-version = "0.4.27"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895"
+checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86"
dependencies = [
"proc-macro2",
"quote",
@@ -821,7 +827,7 @@ version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2a7bc6b2a29e632e45451c941832803a18cce6781db04de8a04696cdca8bde4"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"log",
"wepoll-sys",
@@ -1034,7 +1040,7 @@ version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"redox_syscall",
"winapi",
@@ -1042,9 +1048,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.46"
+version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ad5de3220ea04da322618ded2c42233d02baca219d6f160a3e9c87cda16c942"
+checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
dependencies = [
"proc-macro2",
"quote",
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index ffd909a4..0c5d8b91 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -10,7 +10,7 @@ edition = "2018"
helix-core = { path = "../helix-core" }
helix-view = { path = "../helix-view" }
-lsp-types = { version = "0.82", features = ["proposed"] }
+lsp-types = { version = "0.83", features = ["proposed"] }
smol = "1.2"
url = "2"
pathdiff = "0.2"
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 3c2c1ce0..1583bfb8 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -9,6 +9,7 @@ use helix_core::{ChangeSet, Transaction};
use helix_view::Document;
// use std::collections::HashMap;
+use std::sync::atomic::{AtomicU64, Ordering};
use jsonrpc_core as jsonrpc;
use lsp_types as lsp;
@@ -29,7 +30,7 @@ pub struct Client {
outgoing: Sender<Payload>,
pub incoming: Receiver<Call>,
- pub request_counter: u64,
+ pub request_counter: AtomicU64,
capabilities: Option<lsp::ServerCapabilities>,
// TODO: handle PublishDiagnostics Version
@@ -61,17 +62,16 @@ impl Client {
outgoing,
incoming,
- request_counter: 0,
+ request_counter: AtomicU64::new(0),
capabilities: None,
// diagnostics: HashMap::new(),
}
}
- fn next_request_id(&mut self) -> jsonrpc::Id {
- let id = jsonrpc::Id::Num(self.request_counter);
- self.request_counter += 1;
- id
+ fn next_request_id(&self) -> jsonrpc::Id {
+ let id = self.request_counter.fetch_add(1, Ordering::Relaxed);
+ jsonrpc::Id::Num(id)
}
fn to_params(value: Value) -> Result<jsonrpc::Params> {
@@ -88,10 +88,7 @@ impl Client {
}
/// Execute a RPC request on the language server.
- pub async fn request<R: lsp::request::Request>(
- &mut self,
- params: R::Params,
- ) -> Result<R::Result>
+ pub async fn request<R: lsp::request::Request>(&self, params: R::Params) -> Result<R::Result>
where
R::Params: serde::Serialize,
R::Result: core::fmt::Debug, // TODO: temporary
@@ -128,10 +125,7 @@ impl Client {
}
/// Send a RPC notification to the language server.
- pub async fn notify<R: lsp::notification::Notification>(
- &mut self,
- params: R::Params,
- ) -> Result<()>
+ pub async fn notify<R: lsp::notification::Notification>(&self, params: R::Params) -> Result<()>
where
R::Params: serde::Serialize,
{
@@ -153,7 +147,7 @@ impl Client {
/// Reply to a language server RPC call.
pub async fn reply(
- &mut self,
+ &self,
id: jsonrpc::Id,
result: core::result::Result<Value, jsonrpc::Error>,
) -> Result<()> {
@@ -212,11 +206,11 @@ impl Client {
Ok(())
}
- pub async fn shutdown(&mut self) -> Result<()> {
+ pub async fn shutdown(&self) -> Result<()> {
self.request::<lsp::request::Shutdown>(()).await
}
- pub async fn exit(&mut self) -> Result<()> {
+ pub async fn exit(&self) -> Result<()> {
self.notify::<lsp::notification::Exit>(()).await
}
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 802dd399..a4a3cf09 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -8,6 +8,8 @@ use helix_view::{
Document, Editor, Theme, View,
};
+use log::{debug, info};
+
use std::{
borrow::Cow,
io::{self, stdout, Stdout, Write},
@@ -46,7 +48,7 @@ pub struct Application<'a> {
keymap: Keymaps,
executor: &'a smol::Executor<'a>,
- lsp: helix_lsp::Client,
+ language_server: helix_lsp::Client,
}
struct Renderer {
@@ -370,7 +372,7 @@ impl<'a> Application<'a> {
editor.open(file, terminal.size)?;
}
- let lsp = helix_lsp::Client::start(&executor, "rust-analyzer", &[]);
+ let language_server = helix_lsp::Client::start(&executor, "rust-analyzer", &[]);
let mut app = Self {
editor,
@@ -381,7 +383,7 @@ impl<'a> Application<'a> {
//
keymap: keymap::default(),
executor,
- lsp,
+ language_server,
};
Ok(app)
@@ -415,11 +417,11 @@ impl<'a> Application<'a> {
let mut reader = EventStream::new();
// initialize lsp
- let res = self.lsp.initialize().await;
- let res = self
- .lsp
+ self.language_server.initialize().await.unwrap();
+ self.language_server
.text_document_did_open(&self.editor.view().unwrap().doc)
- .await;
+ .await
+ .unwrap();
self.render();
@@ -433,8 +435,8 @@ impl<'a> Application<'a> {
event = reader.next().fuse() => {
self.handle_terminal_events(event).await
}
- call = self.lsp.incoming.next().fuse() => {
- self.handle_lsp_message(call).await
+ call = self.language_server.incoming.next().fuse() => {
+ self.handle_language_server_message(call).await
}
}
}
@@ -566,7 +568,7 @@ impl<'a> Application<'a> {
};
}
- pub async fn handle_lsp_message(&mut self, call: Option<helix_lsp::Call>) {
+ pub async fn handle_language_server_message(&mut self, call: Option<helix_lsp::Call>) {
use helix_lsp::{Call, Notification};
match call {
Some(Call::Notification(helix_lsp::jsonrpc::Notification {
@@ -605,6 +607,7 @@ impl<'a> Application<'a> {
view.doc.diagnostics = diagnostics;
+ // TODO: we want to process all the events in queue, then render. publishDiagnostic tends to send a whole bunch of events
self.render();
}
}
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index 52e09dd6..f2e62044 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -404,6 +404,8 @@ fn append_changes_to_history(view: &mut View) {
let old_state = std::mem::replace(&mut view.doc.old_state, view.doc.state.clone());
// TODO: take transaction by value?
view.doc.history.commit_revision(&transaction, &old_state);
+
+ // TODO: notify LSP of changes
}
pub fn normal_mode(view: &mut View, _count: usize) {