diff --git a/Cargo.lock b/Cargo.lock index 38cd0e1c..faa464bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1393,10 +1393,10 @@ dependencies = [ "globset", "helix-core", "helix-loader", + "helix-lsp-types", "helix-parsec", "helix-stdx", "log", - "lsp-types", "parking_lot", "serde", "serde_json", @@ -1732,19 +1732,6 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -[[package]] -name = "lsp-types" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e34d33a8e9b006cd3fc4fe69a921affa097bae4bb65f76271f4644f9a334365" -dependencies = [ - "bitflags 1.3.2", - "serde", - "serde_json", - "serde_repr", - "url", -] - [[package]] name = "memchr" version = "2.6.3" diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index ab9251eb..f4e7c794 100644 --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -17,13 +17,13 @@ helix-stdx = { path = "../helix-stdx" } helix-core = { path = "../helix-core" } helix-loader = { path = "../helix-loader" } helix-parsec = { path = "../helix-parsec" } +helix-lsp-types = { path = "../helix-lsp-types" } anyhow = "1.0" futures-executor = "0.3" futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } globset = "0.4.14" log = "0.4" -lsp-types = { version = "0.95" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.38", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 643aa9a2..cc1c4ce8 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -5,15 +5,14 @@ use crate::{ Call, Error, LanguageServerId, OffsetEncoding, Result, }; -use helix_core::{find_workspace, syntax::LanguageServerFeature, ChangeSet, Rope}; -use helix_loader::VERSION_AND_GIT_HASH; -use helix_stdx::path; -use lsp::{ - notification::DidChangeWorkspaceFolders, CodeActionCapabilityResolveSupport, +use crate::lsp::{ + self, notification::DidChangeWorkspaceFolders, CodeActionCapabilityResolveSupport, DidChangeWorkspaceFoldersParams, OneOf, PositionEncodingKind, SignatureHelp, Url, WorkspaceFolder, WorkspaceFoldersChangeEvent, }; -use lsp_types as lsp; +use helix_core::{find_workspace, syntax::LanguageServerFeature, ChangeSet, Rope}; +use helix_loader::VERSION_AND_GIT_HASH; +use helix_stdx::path; use parking_lot::Mutex; use serde::Deserialize; use serde_json::Value; @@ -994,7 +993,7 @@ impl Client { .. }) => match options.as_ref()? { lsp::TextDocumentSyncSaveOptions::Supported(true) => false, - lsp::TextDocumentSyncSaveOptions::SaveOptions(lsp_types::SaveOptions { + lsp::TextDocumentSyncSaveOptions::SaveOptions(lsp::SaveOptions { include_text, }) => include_text.unwrap_or(false), lsp::TextDocumentSyncSaveOptions::Supported(false) => return None, diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 8e423e1c..993a712d 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -8,9 +8,9 @@ mod transport; use arc_swap::ArcSwap; pub use client::Client; pub use futures_executor::block_on; +pub use helix_lsp_types as lsp; pub use jsonrpc::Call; pub use lsp::{Position, Url}; -pub use lsp_types as lsp; use futures_util::stream::select_all::SelectAll; use helix_core::syntax::{ @@ -1113,7 +1113,7 @@ mod tests { #[test] fn emoji_format_gh_4791() { - use lsp_types::{Position, Range, TextEdit}; + use lsp::{Position, Range, TextEdit}; let edits = vec![ TextEdit { diff --git a/helix-lsp/src/transport.rs b/helix-lsp/src/transport.rs index bd671abe..1bded598 100644 --- a/helix-lsp/src/transport.rs +++ b/helix-lsp/src/transport.rs @@ -1,4 +1,8 @@ -use crate::{jsonrpc, Error, LanguageServerId, Result}; +use crate::{ + jsonrpc, + lsp::{self, notification::Notification as _}, + Error, LanguageServerId, Result, +}; use anyhow::Context; use log::{error, info}; use serde::{Deserialize, Serialize}; @@ -289,11 +293,10 @@ impl Transport { } // Hack: inject a terminated notification so we trigger code that needs to happen after exit - use lsp_types::notification::Notification as _; let notification = ServerMessage::Call(jsonrpc::Call::Notification(jsonrpc::Notification { jsonrpc: None, - method: lsp_types::notification::Exit::METHOD.to_string(), + method: lsp::notification::Exit::METHOD.to_string(), params: jsonrpc::Params::None, })); match transport @@ -338,8 +341,8 @@ impl Transport { // Determine if a message is allowed to be sent early fn is_initialize(payload: &Payload) -> bool { - use lsp_types::{ - notification::{Initialized, Notification}, + use lsp::{ + notification::Initialized, request::{Initialize, Request}, }; match payload { @@ -357,7 +360,7 @@ impl Transport { } fn is_shutdown(payload: &Payload) -> bool { - use lsp_types::request::{Request, Shutdown}; + use lsp::request::{Request, Shutdown}; matches!(payload, Payload::Request { value: jsonrpc::MethodCall { method, .. }, .. } if method == Shutdown::METHOD) } @@ -370,12 +373,11 @@ impl Transport { // server successfully initialized is_pending = false; - use lsp_types::notification::Notification; // Hack: inject an initialized notification so we trigger code that needs to happen after init let notification = ServerMessage::Call(jsonrpc::Call::Notification(jsonrpc::Notification { jsonrpc: None, - method: lsp_types::notification::Initialized::METHOD.to_string(), + method: lsp::notification::Initialized::METHOD.to_string(), params: jsonrpc::Params::None, })); let language_server_name = &transport.name;