Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'src/commands.rs')
-rw-r--r--src/commands.rs61
1 files changed, 43 insertions, 18 deletions
diff --git a/src/commands.rs b/src/commands.rs
index 1273cfe..b020c22 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -11,7 +11,7 @@ use lsp_types::*;
use rootcause::{bail, report};
use rust_analyzer::lsp::ext::*;
-use crate::FG;
+use crate::edi::lsp_mn::LSPM;
use crate::edi::{Editor, lsp};
use crate::gotolist::{At, GoToList};
use crate::lsp::{PathURI, Rq, tdpp};
@@ -19,6 +19,7 @@ use crate::menu::charc;
use crate::menu::generic::{CorA, GenericMenu, MenuData};
use crate::sym::GoTo;
use crate::text::{Bookmark, RopeExt, SortTedits, TextArea, col, color_};
+use crate::{FG, KillRing};
macro_rules! repl {
($x:ty, $($with:tt)+) => {
@@ -115,6 +116,10 @@ commands!(
@ Incoming: "callers-of",
/// Functions this function calls
@ Outgoing: "calling",
+ /// loads up the kill ring
+ | KillRing: "killring",
+ /// Reloads the file from disk.
+ | Reload: "reload",
// /// View child modules
// @ ViewChildModules: "child-modules",
/// GoTo line,
@@ -129,6 +134,7 @@ commands!(
pub enum Cmds {}
impl MenuData for Cmds {
+ const NAME: &'static str = "commands";
const HEIGHT: usize = 30;
type Data = ();
type Element<'a> = Cmd;
@@ -222,6 +228,8 @@ impl Editor {
&mut self,
z: Cmd,
w: Arc<dyn winit::window::Window>,
+ kr: &mut KillRing,
+ lsp_mn: &mut LSPM,
) -> rootcause::Result<()> {
match z {
Cmd::GoTo(Some(x)) =>
@@ -271,7 +279,19 @@ impl Editor {
..default()
});
}
- z if z.needs_lsp() => return self.handle_lsp_command(z, w),
+ Cmd::KillRing => {
+ self.state = crate::edi::st::State::KillRing(
+ crate::killring::KillRM {
+ data: kr.clone(),
+ tedit: default(),
+ selection: 0,
+ vo: 0,
+ },
+ );
+ }
+ Cmd::Reload => self.reload(),
+ z if z.needs_lsp() =>
+ return self.handle_lsp_command(z, w, lsp_mn),
x => unimplemented!("{x:?}"),
}
@@ -281,6 +301,7 @@ impl Editor {
&mut self,
z: Cmd,
w: Arc<dyn winit::window::Window>,
+ lsp_mn: &mut LSPM,
) -> rootcause::Result<()> {
let Some((l, o)) = lsp!(self + p) else {
bail!("no lsp");
@@ -291,7 +312,7 @@ impl Editor {
.text
.to_l_position(*self.text.cursor.first())
.unwrap();
- let mut x = l.request_immediate::<rust_analyzer::lsp::ext::MoveItem>(&MoveItemParams {
+ let mut x = l.request_immediate::<rust_analyzer::lsp::ext::MoveItemRequest>(&MoveItemParams {
direction: if let Cmd::RAMoveIU = z { MoveItemDirection::Up } else { MoveItemDirection::Down },
text_document: o.tid(),
range: Range { start : r, end : r},
@@ -303,11 +324,11 @@ impl Editor {
}
}
Cmd::RARestart => {
- _ = l.request::<ReloadWorkspace>(&())?.0;
+ _ = l.request::<ReloadWorkspaceRequest>(&())?.0;
}
Cmd::RAParent => {
- let Some(GotoDefinitionResponse::Link([ref x])) =
- l.request_immediate::<ParentModule>(
+ let Some(DefinitionResponse::DefinitionLinkList([ref x])) =
+ l.request_immediate::<ParentModuleRequest>(
&TextDocumentPositionParams {
text_document: o.tid(),
position: self
@@ -320,11 +341,11 @@ impl Editor {
self.bar.last_action = "no such parent".into();
return Ok(());
};
- self.go(x, w)?;
+ self.go(x, w, lsp_mn)?;
}
Cmd::RAJoinLines => {
- let teds =
- l.request_immediate::<JoinLines>(&JoinLinesParams {
+ let teds = l.request_immediate::<JoinLinesRequest>(
+ &JoinLinesParams {
ranges: self
.text
.cursor
@@ -336,13 +357,14 @@ impl Editor {
})
.collect(),
text_document: o.tid(),
- })?;
+ },
+ )?;
self.text
.apply_tedits(&mut { teds })
.map_err(|_| report!("couldnt apply edits"))?;
}
Cmd::RADocs => {
- let u = l.request_immediate::<ExternalDocs>(
+ let u = l.request_immediate::<ExternalDocsRequest>(
&TextDocumentPositionParams {
position: self
.text
@@ -384,18 +406,19 @@ impl Editor {
.unwrap();
}
Cmd::RARebuildProcMacros => {
- _ = l.request::<RebuildProcMacros>(&())?;
+ _ = l.request::<RebuildProcMacrosRequest>(&())?;
}
- Cmd::RACancelFlycheck => l.notify::<CancelFlycheck>(&())?,
+ Cmd::RACancelFlycheck =>
+ l.notify::<CancelFlycheckNotification>(&())?,
Cmd::RAOpenCargoToml => {
- let Some(GotoDefinitionResponse::Scalar(x)) =
- &l.request_immediate::<OpenCargoToml>(
+ let Some(DefinitionResponse::Definition(x)) =
+ &l.request_immediate::<OpenCargoTomlRequest>(
&OpenCargoTomlParams { text_document: o.tid() },
)?
else {
bail!("wtf?");
};
- self.go(x, w)?;
+ self.go(x, w, lsp_mn)?;
}
Cmd::RARunnables => {
let p = self.text.to_l_position(*self.text.cursor.first());
@@ -415,7 +438,8 @@ impl Editor {
..default()
}),
Cmd::Incoming => {
- let x = l.runtime.spawn(l.callers(tdpp!(self)));
+ let l2 = l.clone();
+ let x = l.runtime.spawn(l2.callers(tdpp!(self)));
self.state = crate::edi::st::State::GoToL(GoToList {
data: (
vec![],
@@ -425,7 +449,8 @@ impl Editor {
});
}
Cmd::Outgoing => {
- let x = l.runtime.spawn(l.calling(tdpp!(self)));
+ let l2 = l.clone();
+ let x = l.runtime.spawn(l2.calling(tdpp!(self)));
self.state = crate::edi::st::State::GoToL(GoToList {
data: (
vec![],