From d686c8eb67c0234d533b7d4a196d8a27f26eb02d Mon Sep 17 00:00:00 2001 From: dannasessha Date: Tue, 2 Nov 2021 02:35:49 +0000 Subject: [PATCH 01/18] squashed WIP commits --- helix-term/src/application.rs | 2 +- helix-term/src/commands.rs | 3 ++- helix-term/src/ui/mod.rs | 3 ++- helix-view/src/editor.rs | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index b04eef0d8914..28fb87c5bf55 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -120,7 +120,7 @@ impl Application { if first.is_dir() { std::env::set_current_dir(&first)?; editor.new_file(Action::VerticalSplit); - compositor.push(Box::new(ui::file_picker(".".into()))); + compositor.push(Box::new(ui::file_picker(".".into(), config.editor.clone()))); } else { let nr_of_files = args.files.len(); editor.open(first.to_path_buf(), Action::VerticalSplit)?; diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 489308d878df..1c433fa8d49f 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2593,7 +2593,8 @@ fn command_mode(cx: &mut Context) { fn file_picker(cx: &mut Context) { let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); - let picker = ui::file_picker(root); + let picker = ui::file_picker(root, cx.editor.config.clone()); + //let picker = ui::file_picker(root, None); cx.push_layer(Box::new(picker)); } diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 62da0dce8218..f9521839877a 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -93,13 +93,14 @@ pub fn regex_prompt( ) } -pub fn file_picker(root: PathBuf) -> FilePicker { +pub fn file_picker(root: PathBuf, config: helix_view::editor::Config) -> FilePicker { use ignore::{types::TypesBuilder, WalkBuilder}; use std::time; // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); + walk_builder.git_ignore(config.show_hidden_files); let walk_builder = match type_builder.add( "compressed", "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 7650d217f459..ac1ce0395853 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -61,6 +61,7 @@ pub struct Config { pub completion_trigger_len: u8, /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, + pub show_hidden_files: bool, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize)] @@ -92,6 +93,7 @@ impl Default for Config { idle_timeout: Duration::from_millis(400), completion_trigger_len: 2, auto_info: true, + show_hidden_files: false, } } } From 1f69124774a1de3bb62817e51815e768db3a349c Mon Sep 17 00:00:00 2001 From: dannasessha Date: Fri, 5 Nov 2021 07:38:39 +0000 Subject: [PATCH 02/18] hide_gitignore working with config --- helix-term/src/commands.rs | 1 - helix-term/src/ui/mod.rs | 2 +- helix-view/src/editor.rs | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 1c433fa8d49f..e7884b1d8c80 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2594,7 +2594,6 @@ fn command_mode(cx: &mut Context) { fn file_picker(cx: &mut Context) { let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); let picker = ui::file_picker(root, cx.editor.config.clone()); - //let picker = ui::file_picker(root, None); cx.push_layer(Box::new(picker)); } diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index f9521839877a..4a3968640f54 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -100,7 +100,7 @@ pub fn file_picker(root: PathBuf, config: helix_view::editor::Config) -> FilePic // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); - walk_builder.git_ignore(config.show_hidden_files); + walk_builder.git_ignore(config.hide_gitignore); let walk_builder = match type_builder.add( "compressed", "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index ac1ce0395853..5589aa7b5676 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -61,7 +61,7 @@ pub struct Config { pub completion_trigger_len: u8, /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, - pub show_hidden_files: bool, + pub hide_gitignore: bool, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize)] @@ -93,7 +93,7 @@ impl Default for Config { idle_timeout: Duration::from_millis(400), completion_trigger_len: 2, auto_info: true, - show_hidden_files: false, + hide_gitignore: false, } } } From e049182b587de47866719dbb7a48b02468d2efed Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sun, 7 Nov 2021 06:35:04 +0000 Subject: [PATCH 03/18] pass reference to new config parameter of file_picker() --- helix-term/src/application.rs | 2 +- helix-term/src/commands.rs | 2 +- helix-term/src/ui/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 28fb87c5bf55..e12106a933ff 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -120,7 +120,7 @@ impl Application { if first.is_dir() { std::env::set_current_dir(&first)?; editor.new_file(Action::VerticalSplit); - compositor.push(Box::new(ui::file_picker(".".into(), config.editor.clone()))); + compositor.push(Box::new(ui::file_picker(".".into(), &config.editor))); } else { let nr_of_files = args.files.len(); editor.open(first.to_path_buf(), Action::VerticalSplit)?; diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e7884b1d8c80..7f4aefda733b 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2593,7 +2593,7 @@ fn command_mode(cx: &mut Context) { fn file_picker(cx: &mut Context) { let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); - let picker = ui::file_picker(root, cx.editor.config.clone()); + let picker = ui::file_picker(root, &cx.editor.config); cx.push_layer(Box::new(picker)); } diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 4a3968640f54..575481c0f462 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -93,7 +93,7 @@ pub fn regex_prompt( ) } -pub fn file_picker(root: PathBuf, config: helix_view::editor::Config) -> FilePicker { +pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePicker { use ignore::{types::TypesBuilder, WalkBuilder}; use std::time; From 07955f9ad87859c328ce744375340ff9e6c00395 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Wed, 10 Nov 2021 02:28:42 +0000 Subject: [PATCH 04/18] update config option name to match name on walk builder --- helix-term/src/ui/mod.rs | 2 +- helix-view/src/editor.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 575481c0f462..1e0c59994af2 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -100,7 +100,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); - walk_builder.git_ignore(config.hide_gitignore); + walk_builder.git_ignore(config.git_ignore); let walk_builder = match type_builder.add( "compressed", "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5589aa7b5676..ccb350416572 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -61,7 +61,7 @@ pub struct Config { pub completion_trigger_len: u8, /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, - pub hide_gitignore: bool, + pub git_ignore: bool, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize)] @@ -93,7 +93,7 @@ impl Default for Config { idle_timeout: Duration::from_millis(400), completion_trigger_len: 2, auto_info: true, - hide_gitignore: false, + git_ignore: false, } } } From 45c131cc605be96dbe40e119ca46c814ce9a604c Mon Sep 17 00:00:00 2001 From: dannasessha Date: Wed, 10 Nov 2021 02:35:13 +0000 Subject: [PATCH 05/18] add comments to config and documentation of option to book --- book/src/configuration.md | 1 + helix-view/src/editor.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/book/src/configuration.md b/book/src/configuration.md index be25441f5ed3..56f76d56807f 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -23,6 +23,7 @@ To override global configuration parameters, create a `config.toml` file located | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | `auto-info` | Whether to display infoboxes | `true` | +| `git_ignore` | Whether to hide files listed in .gitignore in filepicker. | `false` | ## LSP diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index ccb350416572..22883cd00fcf 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -61,6 +61,7 @@ pub struct Config { pub completion_trigger_len: u8, /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, + /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. pub git_ignore: bool, } From 339325f58b4140793c4c97783d042e51595609ad Mon Sep 17 00:00:00 2001 From: dannasessha Date: Wed, 10 Nov 2021 04:00:25 +0000 Subject: [PATCH 06/18] add git_ignore option to WalkBuilder within prompt in commands.rs --- helix-term/src/commands.rs | 71 +++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7f4aefda733b..2b96a37b7504 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1359,6 +1359,7 @@ fn global_search(cx: &mut Context) { let (all_matches_sx, all_matches_rx) = tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>(); let smart_case = cx.editor.config.smart_case; + let git_ignore = cx.editor.config.git_ignore; let completions = search_completions(cx, None); let prompt = ui::regex_prompt( @@ -1387,41 +1388,49 @@ fn global_search(cx: &mut Context) { let search_root = std::env::current_dir() .expect("Global search error: Failed to get current dir"); - WalkBuilder::new(search_root).build_parallel().run(|| { - let mut searcher_cl = searcher.clone(); - let matcher_cl = matcher.clone(); - let all_matches_sx_cl = all_matches_sx.clone(); - Box::new(move |dent: Result| -> WalkState { - let dent = match dent { - Ok(dent) => dent, - Err(_) => return WalkState::Continue, - }; - - match dent.file_type() { - Some(fi) => { - if !fi.is_file() { - return WalkState::Continue; + WalkBuilder::new(search_root) + .git_ignore(git_ignore) + .build_parallel() + .run(|| { + let mut searcher_cl = searcher.clone(); + let matcher_cl = matcher.clone(); + let all_matches_sx_cl = all_matches_sx.clone(); + Box::new(move |dent: Result| -> WalkState { + let dent = match dent { + Ok(dent) => dent, + Err(_) => return WalkState::Continue, + }; + + match dent.file_type() { + Some(fi) => { + if !fi.is_file() { + return WalkState::Continue; + } } + None => return WalkState::Continue, } - None => return WalkState::Continue, - } - let result_sink = sinks::UTF8(|line_num, _| { - match all_matches_sx_cl - .send((line_num as usize - 1, dent.path().to_path_buf())) - { - Ok(_) => Ok(true), - Err(_) => Ok(false), + let result_sink = sinks::UTF8(|line_num, _| { + match all_matches_sx_cl + .send((line_num as usize - 1, dent.path().to_path_buf())) + { + Ok(_) => Ok(true), + Err(_) => Ok(false), + } + }); + let result = + searcher_cl.search_path(&matcher_cl, dent.path(), result_sink); + + if let Err(err) = result { + log::error!( + "Global search error: {}, {}", + dent.path().display(), + err + ); } - }); - let result = searcher_cl.search_path(&matcher_cl, dent.path(), result_sink); - - if let Err(err) = result { - log::error!("Global search error: {}, {}", dent.path().display(), err); - } - WalkState::Continue - }) - }); + WalkState::Continue + }) + }); } else { // Otherwise do nothing // log::warn!("Global Search Invalid Pattern") From 69e9bc88ea8851f29134bd33f71b8d30e59ad4b2 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Fri, 12 Nov 2021 11:35:47 +0000 Subject: [PATCH 07/18] WIP: add FilePickerConfig struct --- helix-term/src/commands.rs | 5 +++-- helix-term/src/ui/mod.rs | 10 +++++++++- helix-view/src/editor.rs | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 2b96a37b7504..a8e7534948a2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1359,7 +1359,7 @@ fn global_search(cx: &mut Context) { let (all_matches_sx, all_matches_rx) = tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>(); let smart_case = cx.editor.config.smart_case; - let git_ignore = cx.editor.config.git_ignore; + let file_picker_config = cx.editor.config.file_picker.clone(); let completions = search_completions(cx, None); let prompt = ui::regex_prompt( @@ -1389,7 +1389,8 @@ fn global_search(cx: &mut Context) { let search_root = std::env::current_dir() .expect("Global search error: Failed to get current dir"); WalkBuilder::new(search_root) - .git_ignore(git_ignore) + .git_ignore(file_picker_config.git_ignore) + // etc .build_parallel() .run(|| { let mut searcher_cl = searcher.clone(); diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 1e0c59994af2..81c85d44a3bb 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -100,7 +100,15 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); - walk_builder.git_ignore(config.git_ignore); + //from 'standard filters' + // reduce with fluent notation? + walk_builder.hidden(config.file_picker.hidden); + walk_builder.parents(config.file_picker.parents); + walk_builder.ignore(config.file_picker.ignore); + walk_builder.git_ignore(config.file_picker.git_ignore); + walk_builder.git_global(config.file_picker.git_global); + walk_builder.git_exclude(config.file_picker.git_exclude); + let walk_builder = match type_builder.add( "compressed", "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 22883cd00fcf..5657cc0a009d 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -34,6 +34,37 @@ where Ok(Duration::from_millis(millis)) } +#[derive(Debug, Clone, PartialEq, Deserialize)] +#[serde(rename_all = "kebab-case", default, deny_unknown_fields)] +pub struct FilePickerConfig { + pub hidden: bool, + pub parents: bool, + pub ignore: bool, + pub git_ignore: bool, + pub git_global: bool, + pub git_exclude: bool, +} + +impl Default for FilePickerConfig { + fn default() -> Self { + Self { + // Enables ignoring hidden files. + hidden: false, + // Enables reading ignore files from parent directories. + parents: false, + // Enables reading `.ignore` files. + ignore: false, + // Enables reading `.gitignore` files. + /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. + git_ignore: false, + // Enables reading global .gitignore, whose path is specified in git's `core.excludesFile` option. + git_global: false, + // Enables reading `.git/info/exclude` files. + git_exclude: false, + } + } +} + #[derive(Debug, Clone, PartialEq, Deserialize)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct Config { @@ -62,7 +93,8 @@ pub struct Config { /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. - pub git_ignore: bool, + //pub git_ignore: bool, + pub file_picker: FilePickerConfig, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize)] @@ -94,7 +126,7 @@ impl Default for Config { idle_timeout: Duration::from_millis(400), completion_trigger_len: 2, auto_info: true, - git_ignore: false, + file_picker: FilePickerConfig::default(), } } } From 0740957a5302609fd8e7651dda0164fff77803b9 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Fri, 12 Nov 2021 12:21:41 +0000 Subject: [PATCH 08/18] WIP: cleanup --- helix-term/src/commands.rs | 6 +++++- helix-term/src/ui/mod.rs | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a8e7534948a2..68fb65eeb855 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1389,8 +1389,12 @@ fn global_search(cx: &mut Context) { let search_root = std::env::current_dir() .expect("Global search error: Failed to get current dir"); WalkBuilder::new(search_root) + .hidden(file_picker_config.hidden) + .parents(file_picker_config.parents) + .ignore(file_picker_config.ignore) .git_ignore(file_picker_config.git_ignore) - // etc + .git_global(file_picker_config.git_global) + .git_exclude(file_picker_config.git_exclude) .build_parallel() .run(|| { let mut searcher_cl = searcher.clone(); diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 81c85d44a3bb..b5a434eb95c4 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -100,14 +100,14 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); - //from 'standard filters' - // reduce with fluent notation? - walk_builder.hidden(config.file_picker.hidden); - walk_builder.parents(config.file_picker.parents); - walk_builder.ignore(config.file_picker.ignore); - walk_builder.git_ignore(config.file_picker.git_ignore); - walk_builder.git_global(config.file_picker.git_global); - walk_builder.git_exclude(config.file_picker.git_exclude); + // from 'standard filters' + walk_builder + .hidden(config.file_picker.hidden) + .parents(config.file_picker.parents) + .ignore(config.file_picker.ignore) + .git_ignore(config.file_picker.git_ignore) + .git_global(config.file_picker.git_global) + .git_exclude(config.file_picker.git_exclude); let walk_builder = match type_builder.add( "compressed", From 5fd9dca239aef7ff9884a9053656e0ffed2ddcda Mon Sep 17 00:00:00 2001 From: dannasessha Date: Fri, 12 Nov 2021 15:18:06 +0000 Subject: [PATCH 09/18] WIP: add more options including max_depth --- helix-term/src/commands.rs | 13 +++++++------ helix-term/src/ui/mod.rs | 5 +++-- helix-view/src/editor.rs | 8 +++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 68fb65eeb855..e3ae3eb36bc1 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1389,12 +1389,13 @@ fn global_search(cx: &mut Context) { let search_root = std::env::current_dir() .expect("Global search error: Failed to get current dir"); WalkBuilder::new(search_root) - .hidden(file_picker_config.hidden) - .parents(file_picker_config.parents) - .ignore(file_picker_config.ignore) - .git_ignore(file_picker_config.git_ignore) - .git_global(file_picker_config.git_global) - .git_exclude(file_picker_config.git_exclude) + // opinionated to look for everything, this is a search? + //.hidden(file_picker_config.hidden) + //.parents(file_picker_config.parents) + //.ignore(file_picker_config.ignore) + //.git_ignore(file_picker_config.git_ignore) + //.git_global(file_picker_config.git_global) + //.git_exclude(file_picker_config.git_exclude) .build_parallel() .run(|| { let mut searcher_cl = searcher.clone(); diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index b5a434eb95c4..3f6ba3143472 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -100,14 +100,15 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi // We want to exclude files that the editor can't handle yet let mut type_builder = TypesBuilder::new(); let mut walk_builder = WalkBuilder::new(&root); - // from 'standard filters' walk_builder .hidden(config.file_picker.hidden) .parents(config.file_picker.parents) .ignore(config.file_picker.ignore) .git_ignore(config.file_picker.git_ignore) .git_global(config.file_picker.git_global) - .git_exclude(config.file_picker.git_exclude); + .git_exclude(config.file_picker.git_exclude) + .follow_links(config.file_picker.git_exclude) + .max_depth(Some(1)); let walk_builder = match type_builder.add( "compressed", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5657cc0a009d..073d29723a9e 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -43,11 +43,15 @@ pub struct FilePickerConfig { pub git_ignore: bool, pub git_global: bool, pub git_exclude: bool, + pub follow_links: bool, + pub max_depth: Option, + // filter_entry - maybe use for a handle to block descent into .git ? } impl Default for FilePickerConfig { fn default() -> Self { Self { + // could simply use .standard_filters if these are uniform. // Enables ignoring hidden files. hidden: false, // Enables reading ignore files from parent directories. @@ -57,10 +61,12 @@ impl Default for FilePickerConfig { // Enables reading `.gitignore` files. /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. git_ignore: false, - // Enables reading global .gitignore, whose path is specified in git's `core.excludesFile` option. + // Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. git_global: false, // Enables reading `.git/info/exclude` files. git_exclude: false, + follow_links: true, + max_depth: Some(1), } } } From 4d1f0fa383e871def22e23ecc497b5fe9cedded4 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sat, 13 Nov 2021 08:11:49 +0000 Subject: [PATCH 10/18] WIP: changed defaults to match ignore crate defaults --- helix-view/src/editor.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 073d29723a9e..d53cb9f67611 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -45,28 +45,30 @@ pub struct FilePickerConfig { pub git_exclude: bool, pub follow_links: bool, pub max_depth: Option, - // filter_entry - maybe use for a handle to block descent into .git ? } impl Default for FilePickerConfig { fn default() -> Self { Self { - // could simply use .standard_filters if these are uniform. + // IgnoreOptions // Enables ignoring hidden files. - hidden: false, + hidden: true, // Enables reading ignore files from parent directories. - parents: false, + parents: true, // Enables reading `.ignore` files. - ignore: false, + ignore: true, // Enables reading `.gitignore` files. /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. - git_ignore: false, + git_ignore: true, // Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. - git_global: false, + git_global: true, // Enables reading `.git/info/exclude` files. - git_exclude: false, - follow_links: true, - max_depth: Some(1), + git_exclude: true, + // WalkBuilder options + // Whether to follow symbolic links. + follow_links: false, + // Maximum Depth to recurse. + max_depth: None, } } } From 8d8aa14f1985405fe23a7898f6575db76ce9815c Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sat, 13 Nov 2021 08:46:25 +0000 Subject: [PATCH 11/18] WIP: change WalkBuilder in global_search() to use config options --- helix-term/src/commands.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e3ae3eb36bc1..5a66d468fdb8 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1389,13 +1389,14 @@ fn global_search(cx: &mut Context) { let search_root = std::env::current_dir() .expect("Global search error: Failed to get current dir"); WalkBuilder::new(search_root) - // opinionated to look for everything, this is a search? - //.hidden(file_picker_config.hidden) - //.parents(file_picker_config.parents) - //.ignore(file_picker_config.ignore) - //.git_ignore(file_picker_config.git_ignore) - //.git_global(file_picker_config.git_global) - //.git_exclude(file_picker_config.git_exclude) + .hidden(file_picker_config.hidden) + .parents(file_picker_config.parents) + .ignore(file_picker_config.ignore) + .git_ignore(file_picker_config.git_ignore) + .git_global(file_picker_config.git_global) + .git_exclude(file_picker_config.git_exclude) + .follow_links(file_picker_config.follow_links) + .max_depth(file_picker_config.max_depth) .build_parallel() .run(|| { let mut searcher_cl = searcher.clone(); From 770e31e8945ec2c6703ead78a14ebc0b5a282505 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sat, 13 Nov 2021 11:27:02 +0000 Subject: [PATCH 12/18] WIP: removed follow_links, changed max_depth to follow config setting --- helix-term/src/commands.rs | 1 - helix-term/src/ui/mod.rs | 3 +-- helix-view/src/editor.rs | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 5a66d468fdb8..e7af95588495 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1395,7 +1395,6 @@ fn global_search(cx: &mut Context) { .git_ignore(file_picker_config.git_ignore) .git_global(file_picker_config.git_global) .git_exclude(file_picker_config.git_exclude) - .follow_links(file_picker_config.follow_links) .max_depth(file_picker_config.max_depth) .build_parallel() .run(|| { diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 3f6ba3143472..cdf423110704 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -107,8 +107,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi .git_ignore(config.file_picker.git_ignore) .git_global(config.file_picker.git_global) .git_exclude(config.file_picker.git_exclude) - .follow_links(config.file_picker.git_exclude) - .max_depth(Some(1)); + .max_depth(config.file_picker.max_depth); let walk_builder = match type_builder.add( "compressed", diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index d53cb9f67611..fc63e043c8c8 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -43,7 +43,6 @@ pub struct FilePickerConfig { pub git_ignore: bool, pub git_global: bool, pub git_exclude: bool, - pub follow_links: bool, pub max_depth: Option, } @@ -65,8 +64,6 @@ impl Default for FilePickerConfig { // Enables reading `.git/info/exclude` files. git_exclude: true, // WalkBuilder options - // Whether to follow symbolic links. - follow_links: false, // Maximum Depth to recurse. max_depth: None, } From c7067449e004ec097cda593a6f9b976b9d33d1fc Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sat, 13 Nov 2021 12:18:08 +0000 Subject: [PATCH 13/18] WIP: update book with file-picker inline table notation --- book/src/configuration.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 56f76d56807f..2b1774b83edf 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -23,7 +23,15 @@ To override global configuration parameters, create a `config.toml` file located | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | `auto-info` | Whether to display infoboxes | `true` | -| `git_ignore` | Whether to hide files listed in .gitignore in filepicker. | `false` | +| `file-picker` | Sets options for file picker and global search. Multiple pairs in an inline table. Details below. | `{hidden = true, parents = true, ignore = false, git-ignore = true, git-global = true, git-exclude = true } | +All the pairs listed in the default configuration above are IgnoreOptions: which types of files are ignored in the file picker and global search. +`hidden` Directly enables ignoring hidden files. +`parents` Enables reading ignore files from parent directories. +`ignore` Enables reading `.ignore` files. +`git-ignore` Enables reading `.gitignore` files. +`git-global` Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. +`git-exclude` Enables reading `.git/info/exclude` files. +`max-depth` can also be used as a key, and can be bound to an integer value for maximum depth to recurse. Defaults to `None`. ## LSP From 5cfb86fcdae295b54cab8b0958ed5fb7810a8881 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Sun, 14 Nov 2021 05:55:01 +0000 Subject: [PATCH 14/18] update documentation for file-picker config in book --- book/src/configuration.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 2b1774b83edf..e2b9da23c713 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -23,15 +23,21 @@ To override global configuration parameters, create a `config.toml` file located | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | `auto-info` | Whether to display infoboxes | `true` | -| `file-picker` | Sets options for file picker and global search. Multiple pairs in an inline table. Details below. | `{hidden = true, parents = true, ignore = false, git-ignore = true, git-global = true, git-exclude = true } | -All the pairs listed in the default configuration above are IgnoreOptions: which types of files are ignored in the file picker and global search. -`hidden` Directly enables ignoring hidden files. -`parents` Enables reading ignore files from parent directories. -`ignore` Enables reading `.ignore` files. -`git-ignore` Enables reading `.gitignore` files. -`git-global` Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. -`git-exclude` Enables reading `.git/info/exclude` files. -`max-depth` can also be used as a key, and can be bound to an integer value for maximum depth to recurse. Defaults to `None`. +| `file-picker` | Sets options for file picker and global search. Supports multiple pairs within an inline table. Details below. | `{hidden = true, parents = true, ignore = true, git-ignore = true, git-global = true, git-exclude = true }` | + +#### file-picker + +All the pairs listed in the default file-picker configuration above are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. + +| Key | Description | Default | +|--|--|---------| +|`hidden` | Directly enables ignoring hidden files. | true +|`parents` | Enables reading ignore files from parent directories. | true +|`ignore` | Enables reading `.ignore` files. | true +|`git-ignore` | Enables reading `.gitignore` files. | true +|`git-global` | Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. | true +|`git-exclude` | Enables reading `.git/info/exclude` files. | true +|`max-depth` | May be used as a key, bound to an integer value for maximum depth to recurse. Defaults within helix logic to `None`. | N/A: not present by default. ## LSP From 80ba0e071f847cf549825e852d29fad2e62eca9c Mon Sep 17 00:00:00 2001 From: dannasessha Date: Mon, 15 Nov 2021 03:01:39 +0000 Subject: [PATCH 15/18] adjusted to [editor.file-picker] in book configuration.md --- book/src/configuration.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index e2b9da23c713..2ac74c07c1ba 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -23,11 +23,8 @@ To override global configuration parameters, create a `config.toml` file located | `idle-timeout` | Time in milliseconds since last keypress before idle timers trigger. Used for autocompletion, set to 0 for instant. | `400` | | `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` | | `auto-info` | Whether to display infoboxes | `true` | -| `file-picker` | Sets options for file picker and global search. Supports multiple pairs within an inline table. Details below. | `{hidden = true, parents = true, ignore = true, git-ignore = true, git-global = true, git-exclude = true }` | -#### file-picker - -All the pairs listed in the default file-picker configuration above are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. +`[editor.filepicker]` section of the config. Sets options for file picker and global search. All but the last key listed in the default file-picker configuration below are IgnoreOptions: whether hidden files and files listed within ignore files are ignored by (not visible in) the helix file picker and global search. There is also one other key, `max-depth` available, which is not defined by default. | Key | Description | Default | |--|--|---------| From 5e07a6ba0ea5ed577696c04de67eb154f947dc50 Mon Sep 17 00:00:00 2001 From: dannasessha Date: Tue, 16 Nov 2021 04:52:20 +0000 Subject: [PATCH 16/18] adjust comments in editor.rs to be doc comments, cleanup --- helix-view/src/editor.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index fc63e043c8c8..32c8b6944af7 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -37,34 +37,38 @@ where #[derive(Debug, Clone, PartialEq, Deserialize)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct FilePickerConfig { + /// IgnoreOptions + /// Enables ignoring hidden files. + /// Whether to hide, that is, to stop hidden files from displaying in file picker. Defaults to false. pub hidden: bool, + /// Enables reading ignore files from parent directories. pub parents: bool, + /// Enables reading `.ignore` files. + /// Whether to hide files listed in .ignore from displaying in file picker. Defaults to false. pub ignore: bool, + /// Enables reading `.gitignore` files. + /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. pub git_ignore: bool, + /// Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. + /// Whether to hide files in global .gitignore from displaying in file picker. Defaults to false. pub git_global: bool, + /// Enables reading `.git/info/exclude` files. + /// Whether to hide files in .git/info/exclude from displaying in file picker. Defaults to false. pub git_exclude: bool, + /// WalkBuilder options + /// Maximum Depth to recurse. pub max_depth: Option, } impl Default for FilePickerConfig { fn default() -> Self { Self { - // IgnoreOptions - // Enables ignoring hidden files. hidden: true, - // Enables reading ignore files from parent directories. parents: true, - // Enables reading `.ignore` files. ignore: true, - // Enables reading `.gitignore` files. - /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. git_ignore: true, - // Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. git_global: true, - // Enables reading `.git/info/exclude` files. git_exclude: true, - // WalkBuilder options - // Maximum Depth to recurse. max_depth: None, } } @@ -97,8 +101,6 @@ pub struct Config { pub completion_trigger_len: u8, /// Whether to display infoboxes. Defaults to true. pub auto_info: bool, - /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. - //pub git_ignore: bool, pub file_picker: FilePickerConfig, } From 3b381dfdbcdf4d8971b09b4fece5bc4a25c2024f Mon Sep 17 00:00:00 2001 From: dannasessha Date: Tue, 16 Nov 2021 16:25:22 +0000 Subject: [PATCH 17/18] adjust comments --- helix-view/src/editor.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 32c8b6944af7..63d88f5e5bf7 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -39,24 +39,24 @@ where pub struct FilePickerConfig { /// IgnoreOptions /// Enables ignoring hidden files. - /// Whether to hide, that is, to stop hidden files from displaying in file picker. Defaults to false. + /// Whether to hide hidden files in file picker and global search results. Defaults to true. pub hidden: bool, - /// Enables reading ignore files from parent directories. + /// Enables reading ignore files from parent directories. Defaults to true. pub parents: bool, /// Enables reading `.ignore` files. - /// Whether to hide files listed in .ignore from displaying in file picker. Defaults to false. + /// Whether to hide files listed in .ignore in file picker and global search results. Defaults to true. pub ignore: bool, /// Enables reading `.gitignore` files. - /// Whether to hide files in .gitignore from displaying in file picker. Defaults to false. + /// Whether to hide files listed in .gitignore in file picker and global search results. Defaults to true. pub git_ignore: bool, /// Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. - /// Whether to hide files in global .gitignore from displaying in file picker. Defaults to false. + /// Whether to hide files listed in global .gitignore in file picker and global search results. Defaults to true. pub git_global: bool, /// Enables reading `.git/info/exclude` files. - /// Whether to hide files in .git/info/exclude from displaying in file picker. Defaults to false. + /// Whether to hide files listed in .git/info/exclude in file picker and global search results. Defaults to true. pub git_exclude: bool, /// WalkBuilder options - /// Maximum Depth to recurse. + /// Maximum Depth to recurse directories in file picker and global search. Defaults to `None`. pub max_depth: Option, } From 92664a073735b57cacba1dd9358cc441787d97fb Mon Sep 17 00:00:00 2001 From: dannasessha Date: Tue, 16 Nov 2021 16:31:02 +0000 Subject: [PATCH 18/18] adjust book --- book/src/configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 2ac74c07c1ba..2ed48d51f962 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -28,13 +28,13 @@ To override global configuration parameters, create a `config.toml` file located | Key | Description | Default | |--|--|---------| -|`hidden` | Directly enables ignoring hidden files. | true +|`hidden` | Enables ignoring hidden files. | true |`parents` | Enables reading ignore files from parent directories. | true |`ignore` | Enables reading `.ignore` files. | true |`git-ignore` | Enables reading `.gitignore` files. | true |`git-global` | Enables reading global .gitignore, whose path is specified in git's config: `core.excludefile` option. | true |`git-exclude` | Enables reading `.git/info/exclude` files. | true -|`max-depth` | May be used as a key, bound to an integer value for maximum depth to recurse. Defaults within helix logic to `None`. | N/A: not present by default. +|`max-depth` | Set with an integer value for maximum depth to recurse. | Defaults to `None`. ## LSP