add require_git option

This commit is contained in:
kirawi 2025-01-10 13:57:46 -05:00
parent 9721144e03
commit 9581e70b0b
3 changed files with 8 additions and 0 deletions

View file

@ -2449,6 +2449,7 @@ fn global_search(cx: &mut Context) {
.parents(config.file_picker_config.parents)
.ignore(config.file_picker_config.ignore)
.follow_links(config.file_picker_config.follow_symlinks)
.require_git(config.file_picker_config.require_git)
.git_ignore(config.file_picker_config.git_ignore)
.git_global(config.file_picker_config.git_global)
.git_exclude(config.file_picker_config.git_exclude)

View file

@ -199,6 +199,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
.parents(config.file_picker.parents)
.ignore(config.file_picker.ignore)
.follow_links(config.file_picker.follow_symlinks)
.require_git(config.file_picker.require_git)
.git_ignore(config.file_picker.git_ignore)
.git_global(config.file_picker.git_global)
.git_exclude(config.file_picker.git_exclude)
@ -480,10 +481,12 @@ pub mod completers {
};
let end = input.len()..;
let require_git = editor.config().file_picker.require_git;
let files = WalkBuilder::new(&dir)
.hidden(false)
.follow_links(false) // We're scanning over depth 1
.require_git(require_git)
.git_ignore(git_ignore)
.max_depth(Some(1))
.build()

View file

@ -188,6 +188,9 @@ pub struct FilePickerConfig {
/// Enables reading `.ignore` files.
/// Whether to hide files listed in .ignore in file picker and global search results. Defaults to true.
pub ignore: bool,
/// Enables `git_*` features only if a `.git` directory is present
/// Defaults to true
pub require_git: bool,
/// Enables reading `.gitignore` files.
/// Whether to hide files listed in .gitignore in file picker and global search results. Defaults to true.
pub git_ignore: bool,
@ -210,6 +213,7 @@ impl Default for FilePickerConfig {
deduplicate_links: true,
parents: true,
ignore: true,
require_git: true,
git_ignore: true,
git_global: true,
git_exclude: true,