From dcde73abd3f13ea4302595f048056cbf11269948 Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Tue, 12 Mar 2024 23:17:01 +0100 Subject: [PATCH] feat: Allow excluding directories Fixes #3 --- README.md | 5 +++++ internal/pkg/repo/discover.go | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 0b0ee5d..5eff3c8 100644 --- a/README.md +++ b/README.md @@ -73,5 +73,10 @@ renameRepo: # Add extra static directories outside of the basedir extraDirs: - $HOME/.config/nvim + +# Exclude directories you don't want to include in the fuzzyfinder +excludeDirs: + - $HOME/src/gitlab.com/oldstuff + ``` diff --git a/internal/pkg/repo/discover.go b/internal/pkg/repo/discover.go index 4fdd61b..f54601d 100644 --- a/internal/pkg/repo/discover.go +++ b/internal/pkg/repo/discover.go @@ -48,6 +48,9 @@ func GetRepoPathsChan(basedir string, includeExtras bool) <-chan string { if !entry.IsDir() { continue } + if inExcludeList(basedir) { + continue + } if entry.Name() == ".git" { out <- basedir return @@ -66,6 +69,16 @@ func GetRepoPathsChan(basedir string, includeExtras bool) <-chan string { return out } +func inExcludeList(name string) bool { + excludes := viper.GetStringSlice("excludeDirs") + for _, exclude := range excludes { + if name == ExpandPath(exclude) { + return true + } + } + return false +} + func GetRepoPathsAsync(baseDir string, result *[]string) error { ch := GetRepoPathsChan(baseDir, true) for p := range ch {