A simple CPU rendered GUI IDE experience.
better rooting
| -rw-r--r-- | src/edi.rs | 25 | ||||
| -rw-r--r-- | src/edi/lsp_mn.rs | 1 | ||||
| -rw-r--r-- | src/lsp.rs | 3 | ||||
| -rw-r--r-- | src/rnd.rs | 36 |
4 files changed, 45 insertions, 20 deletions
@@ -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 { @@ -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() @@ -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"); } |