chore: add common ignore patterns by default

kujtimiihoxha created

Change summary

internal/fsext/ls.go                   | 114 ++++++++++++++-------------
internal/lsp/watcher/global_watcher.go |   3 
2 files changed, 61 insertions(+), 56 deletions(-)

Detailed changes

internal/fsext/ls.go 🔗

@@ -13,64 +13,66 @@ import (
 	ignore "github.com/sabhiram/go-gitignore"
 )
 
+var IgnorePatters = []string{
+	// Version control
+	".git",
+	".svn",
+	".hg",
+	".bzr",
+
+	// IDE and editor files
+	".vscode",
+	".idea",
+	"*.swp",
+	"*.swo",
+	"*~",
+	".DS_Store",
+	"Thumbs.db",
+
+	// Build artifacts and dependencies
+	"node_modules",
+	"target",
+	"build",
+	"dist",
+	"out",
+	"bin",
+	"obj",
+	"*.o",
+	"*.so",
+	"*.dylib",
+	"*.dll",
+	"*.exe",
+
+	// Logs and temporary files
+	"*.log",
+	"*.tmp",
+	"*.temp",
+	".cache",
+	".tmp",
+
+	// Language-specific
+	"__pycache__",
+	"*.pyc",
+	"*.pyo",
+	".pytest_cache",
+	"vendor",
+	"Cargo.lock",
+	"package-lock.json",
+	"yarn.lock",
+	"pnpm-lock.yaml",
+
+	// OS generated files
+	".Trash",
+	".Spotlight-V100",
+	".fseventsd",
+
+	// Crush
+	".crush",
+}
+
 // commonIgnorePatterns contains commonly ignored files and directories
 var commonIgnorePatterns = sync.OnceValue(func() ignore.IgnoreParser {
-	return ignore.CompileIgnoreLines(
-		// Version control
-		".git",
-		".svn",
-		".hg",
-		".bzr",
-
-		// IDE and editor files
-		".vscode",
-		".idea",
-		"*.swp",
-		"*.swo",
-		"*~",
-		".DS_Store",
-		"Thumbs.db",
-
-		// Build artifacts and dependencies
-		"node_modules",
-		"target",
-		"build",
-		"dist",
-		"out",
-		"bin",
-		"obj",
-		"*.o",
-		"*.so",
-		"*.dylib",
-		"*.dll",
-		"*.exe",
-
-		// Logs and temporary files
-		"*.log",
-		"*.tmp",
-		"*.temp",
-		".cache",
-		".tmp",
-
-		// Language-specific
-		"__pycache__",
-		"*.pyc",
-		"*.pyo",
-		".pytest_cache",
-		"vendor",
-		"Cargo.lock",
-		"package-lock.json",
-		"yarn.lock",
-		"pnpm-lock.yaml",
-
-		// OS generated files
-		".Trash",
-		".Spotlight-V100",
-		".fseventsd",
-
-		// Crush
-		".crush",
-	)
+	return ignore.CompileIgnoreLines(IgnorePatters...)
 })
 
 var homeIgnore = sync.OnceValue(func() ignore.IgnoreParser {

internal/lsp/watcher/global_watcher.go 🔗

@@ -386,6 +386,9 @@ func setupIgnoreSystem(root string) error {
 			slog.Warn("lsp watcher: Failed to load .gitignore file", "error", err)
 		}
 	}
+	for _, p := range fsext.IgnorePatters {
+		im.AddPattern(p)
+	}
 
 	// Set as the global ignore matcher
 	notify.SetIgnoreMatcher(im)