A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/lsp.rs')
| -rw-r--r-- | src/lsp.rs | 92 |
1 files changed, 26 insertions, 66 deletions
@@ -24,7 +24,6 @@ use lsp_server::{ use lsp_types::notification::*; use lsp_types::request::*; use lsp_types::*; -use rust_analyzer::lsp::ext::*; use serde::{Deserialize, Serialize}; use serde_json::json; use tokio::sync::oneshot; @@ -64,7 +63,6 @@ pub enum RequestError<X> { Rx(PhantomData<X>), Failure(Re, #[serde(skip)] Option<Backtrace>), Cancelled(Re, DiagnosticServerCancellationData), - Send(Message), } pub type AQErr = RequestError<LSPError>; impl Request for LSPError { @@ -80,7 +78,6 @@ pub trait Anonymize<T> { impl<T, E> Anonymize<T> for Result<T, RequestError<E>> { fn anonymize(self) -> Result<T, RequestError<LSPError>> { self.map_err(|e| match e { - RequestError::Send(x) => RequestError::Send(x), RequestError::Rx(_) => RequestError::Rx(PhantomData), RequestError::Failure(r, b) => RequestError::Failure(r, b), RequestError::Cancelled(r, d) => RequestError::Cancelled(r, d), @@ -99,16 +96,9 @@ impl<X: Request + std::fmt::Debug> std::error::Error for RequestError<X> { None } } -impl<X> From<SendError<Message>> for RequestError<X> { - fn from(x: SendError<Message>) -> Self { - Self::Send(x.into_inner()) - } -} impl<X: Request> Display for RequestError<X> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Send(x) => - write!(f, "{} failed; couldnt send {x:?}", X::METHOD), Self::Rx(_) => write!(f, "{} failed; couldnt get from thingy", X::METHOD), Self::Failure(x, bt) => write!( @@ -134,12 +124,6 @@ impl Client { pub fn cancel(&self, rid: i32) { _ = self.notify::<Cancel>(&CancelParams { id: rid.into() }); } - pub fn request_immediate<'me, X: Request>( - &'me self, - y: &X::Params, - ) -> Result<X::Result, RequestError<X>> { - self.runtime.block_on(self.request::<X>(y)?.0) - } #[must_use] pub fn request<'me, X: Request>( &'me self, @@ -465,14 +449,10 @@ impl Client { >, > { self.request::<lsp_request!("workspace/symbol")>( - &lsp_types::WorkspaceSymbolParams { + &WorkspaceSymbolParams { query: f, - search_scope: Some( - lsp_types::WorkspaceSymbolSearchScope::Workspace, - ), - search_kind: Some( - lsp_types::WorkspaceSymbolSearchKind::AllSymbols, - ), + search_scope: Some(WorkspaceSymbolSearchScope::Workspace), + search_kind: Some(WorkspaceSymbolSearchKind::AllSymbols), ..Default::default() }, ) @@ -484,13 +464,15 @@ impl Client { f: &Path, t: &'a mut TextArea, ) { - if let Ok([x]) = self.runtime.block_on( - self.request::<MatchingBrace>(&MatchingBraceParams { - text_document: f.tid(), - positions: vec![ - t.to_l_position(*t.cursor.first()).unwrap(), - ], - }) + if let Ok(Some([x])) = self.runtime.block_on( + self.request::<lsp_request!("experimental/matchingBrace")>( + &MatchingBraceParams { + text_document: f.tid(), + positions: vec![ + t.to_l_position(*t.cursor.first()).unwrap(), + ], + }, + ) .unwrap() .0, ) { @@ -555,6 +537,14 @@ impl Client { ) .unwrap() .0 + .map(|x| { + x.map(|x| { + x.map(|mut x| { + x.sort_tedits(); + x + }) + }) + }) } pub fn rq_semantic_tokens( &'static self, @@ -603,10 +593,12 @@ impl Client { let r = self .runtime .block_on( - self.request::<OnEnter>(&TextDocumentPositionParams { - text_document: f.tid(), - position: t.to_l_position(*c).unwrap(), - }) + self.request::<lsp_request!("experimental/onEnter")>( + &TextDocumentPositionParams { + text_document: f.tid(), + position: t.to_l_position(*c).unwrap(), + }, + ) .unwrap() .0, ) @@ -622,25 +614,6 @@ impl Client { } }); } - pub fn runnables( - &self, - t: &Path, - c: Option<Position>, - ) -> Result< - impl Future< - Output = Result< - Vec<Runnable>, - RequestError<Runnables>, - >, - >, - SendError<Message>, - > { - self.request::<Runnables>(&RunnablesParams { - text_document: t.tid(), - position: c, - }) - .map(|(x, _)| x) - } } pub fn run( (tx, rx): (Sender<Message>, Receiver<Message>), @@ -695,9 +668,6 @@ pub fn run( ..default() }), text_document: Some(TextDocumentClientCapabilities { - on_type_formatting: Some(DocumentOnTypeFormattingClientCapabilities { - dynamic_registration: Some(false), - }), document_highlight: Some(default()), formatting: Some(DynamicRegistrationClientCapabilities { dynamic_registration: Some(false) }), inlay_hint: Some(InlayHintClientCapabilities { dynamic_registration: None, resolve_support: Some(InlayHintResolveClientCapabilities { @@ -863,7 +833,6 @@ pub fn run( "hoverActions": true, "workspaceSymbolScopeKindFiltering": true, "onEnter": true, - "localDocs": true, }}), ..default() }, @@ -879,11 +848,6 @@ pub fn run( "enable": true, "attributes": { "enable": true } }, - "hover": { - "documentation": { - "keywords": { "enable": false }, - }, - }, "inlayHints": { "closureReturnTypeHints": { "enable": "with_block" }, "closingBraceHints": { "minLines": 5 }, @@ -892,7 +856,6 @@ pub fn run( "rangeExclusiveHints": { "enable": true }, "closureCaptureHints": { "enable": true }, }, - "typing": { "triggerChars": ".=<>{(+" }, "assist": { "preferSelf": true }, "checkOnSave": true, "diagnostics": { "enable": true }, @@ -919,9 +882,6 @@ pub fn run( "autoself": { "enable": true, }, "privateEditable": { "enable": true }, }, - "imports": { - "granularity": "group", - }, }}), trace: None, workspace_folders: Some(vec![workspace]), |