A simple CPU rendered GUI IDE experience.
-rw-r--r--src/edi.rs25
-rw-r--r--src/edi/lsp_mn.rs1
-rw-r--r--src/lsp.rs3
-rw-r--r--src/rnd.rs36
4 files changed, 45 insertions, 20 deletions
diff --git a/src/edi.rs b/src/edi.rs
index 9a591e9..9d01fb8 100644
--- a/src/edi.rs
+++ b/src/edi.rs
@@ -183,20 +183,32 @@ macro_rules! change {
}
pub(crate) use change;
-fn rooter(
+fn rooter_(
x: &Path,
mut search: impl FnMut(OsString) -> bool + Clone,
whilst: impl for<'a> FnMut(&&'a Path) -> bool + Clone,
-) -> Option<PathBuf> {
- for f in std::fs::read_dir(&x).ok()?.filter_map(Result::ok) {
- println!("{f:?}");
+ found: &mut Vec<PathBuf>,
+) {
+ let Some(d) = std::fs::read_dir(&x).ok() else { return };
+ for f in d.filter_map(Result::ok) {
if search(f.file_name()) {
- return Some(f.path().with_file_name("").to_path_buf());
+ found.push(f.path().with_file_name("").to_path_buf());
}
}
x.parent()
.filter(whilst.clone())
- .and_then(rooter.rbind(whilst).rbind(search))
+ .map(|x| rooter_(x, search, whilst, found));
+}
+
+fn rooter(
+ x: &Path,
+ search: impl FnMut(OsString) -> bool + Clone,
+
+ whilst: impl for<'a> FnMut(&&'a Path) -> bool + Clone,
+) -> Option<PathBuf> {
+ let mut v = vec![];
+ rooter_(x, search, whilst, &mut v);
+ v.try_remove(v.len().checked_sub(1)?)
}
impl Editor {
@@ -715,6 +727,7 @@ impl Editor {
.filter_entry(|e| !is_hidden(e))
.flatten()
.filter(|x| !x.path().starts_with("."))
+ .filter(|x| !x.path().is_dir())
.map(|x| x.path().to_owned())
.collect::<Vec<_>>()
});
diff --git a/src/edi/lsp_mn.rs b/src/edi/lsp_mn.rs
index a505e5c..25aa478 100644
--- a/src/edi/lsp_mn.rs
+++ b/src/edi/lsp_mn.rs
@@ -95,7 +95,6 @@ pub fn load(
);
(x, conf, Some(iot))
};
- info!("spawned {conf:?}");
let (c, t2, changed) = crate::lsp::run(
(sender, receiver),
WorkspaceFolder {
diff --git a/src/lsp.rs b/src/lsp.rs
index 8df05fc..5345fbd 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -10,6 +10,7 @@ use helix_core::syntax::config::{
LanguageServerConfiguration, LanguageServerFeatures,
};
use json_value_merge::Merge;
+use log::info;
use lsp_server::Message;
use lsp_types::notification::*;
use lsp_types::request::*;
@@ -67,12 +68,14 @@ pub fn run(
&data.0.config,
data.1.name == "rust-analyzer",
);
+
if let Some(v) = vscode_conf {
match opts.initialization_options {
Some(ref mut x) => x.merge(&v),
None => opts.initialization_options = Some(v),
}
};
+ info!("spawned {}", serde_json::to_string_pretty(&opts).unwrap());
_ = c.request::<Initialize>(&opts)?;
let x = rx
.iter()
diff --git a/src/rnd.rs b/src/rnd.rs
index a401009..2f458ad 100644
--- a/src/rnd.rs
+++ b/src/rnd.rs
@@ -102,7 +102,27 @@ pub fn render(
),
_ => None,
};
-
+ let sym_sel =
+ if let State::Symbols(Rq { result: Some(menu), .. }) =
+ &ed.state
+ && let Some(Ok(UsedSI {
+ at: GoTo { at: At::R(x), .. },
+ ..
+ })) = menu.sel(None)
+ {
+ Some(x)
+ } else {
+ None
+ };
+ let gen_sel = if let State::GoToL(menu) = &ed.state
+ && let Some(Ok((GoTo { at: At::R(r), path }, _))) =
+ menu.sel(None)
+ && Some(&*path) == ed.origin.as_deref()
+ {
+ Some(r)
+ } else {
+ None
+ };
text.line_numbers(
(c, r - 1),
[67, 76, 87],
@@ -110,22 +130,12 @@ pub fn render(
(cells, (c, r)),
(1, 0),
|_text, mut f, y| {
- if let State::GoToL(menu) = &ed.state
- && let Some(Ok((GoTo { at: At::R(r), path }, _))) =
- menu.sel(None)
- && Some(&*path) == ed.origin.as_deref()
- {
+ if let Some(r) = gen_sel {
if (r.start.line..=r.end.line).contains(&(y as _)) {
f.style.fg = col!("#FFCC66");
}
}
- if let State::Symbols(Rq { result: Some(menu), .. }) =
- &ed.state
- && let Some(Ok(UsedSI {
- at: GoTo { at: At::R(x), .. },
- ..
- })) = menu.sel(None)
- {
+ if let Some(x) = sym_sel {
if (x.start.line..=x.end.line).contains(&(y as _)) {
f.style.fg = col!("#FFCC66");
}