pub enum LspEvent {
Hover {
text: String,
},
Completion {
items: Vec<String>,
},
Definition {
uri: String,
range: LspRange,
},
Formatting {
uri: String,
edits: Vec<LspTextChange>,
},
Progress {
token: String,
server_key: String,
title: String,
message: Option<String>,
percentage: Option<u32>,
done: bool,
},
Log {
server_key: String,
message: String,
},
}Expand description
Events that can be sent from the LSP client to the application.
Receive these by polling the mpsc::Receiver you pass to
LspProcessClient::new_with_server. Requests are fire-and-forget, so
every server reply arrives here rather than as a return value — drain the
receiver on a timer and fold the results into the application state.
§Examples
use std::sync::mpsc;
use iced_code_editor::{LspEvent, LSP_EVENT_QUEUE_CAPACITY};
// Bounded: the queue is fed by a language server, so it needs a ceiling.
let (tx, rx) = mpsc::sync_channel::<LspEvent>(LSP_EVENT_QUEUE_CAPACITY);
tx.send(LspEvent::Hover { text: "fn main()".to_string() })
.expect("the receiver is still alive");
// Drain everything queued since the last tick.
while let Ok(event) = rx.try_recv() {
match event {
LspEvent::Hover { text } => assert_eq!(text, "fn main()"),
LspEvent::Completion { items } => drop(items),
LspEvent::Definition { uri, .. } => drop(uri),
LspEvent::Formatting { edits, .. } => drop(edits),
LspEvent::Progress { done, .. } => drop(done),
LspEvent::Log { message, .. } => drop(message),
}
}Variants§
Hover
Hover information received from the LSP server.
Completion
Completion items received from the LSP server.
Definition
Definition location received from the LSP server.
Formatting
Formatting edits received from the LSP server.
Fields
edits: Vec<LspTextChange>Edits to apply, in the document’s own character coordinates.
Apply them with CodeEditor::apply_lsp_text_edits, which takes
care of ordering and of landing them as a single undo step.
Progress
Progress notification from the LSP server.
Fields
Log
Log message from the LSP server’s stderr.
Auto Trait Implementations§
impl Forget for LspEvent
impl Freeze for LspEvent
impl Move for LspEvent
impl RefUnwindSafe for LspEvent
impl Send for LspEvent
impl Sync for LspEvent
impl Unpin for LspEvent
impl UnsafeUnpin for LspEvent
impl UnwindSafe for LspEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.