From 9f3ae09afea818d54086cd4392ea99d3ea0609da Mon Sep 17 00:00:00 2001 From: kujtimiihoxha Date: Tue, 16 Sep 2025 14:01:15 +0200 Subject: [PATCH] chore: add common ignore patterns by default --- internal/fsext/ls.go | 114 +++++++++++++------------ internal/lsp/watcher/global_watcher.go | 3 + 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/internal/fsext/ls.go b/internal/fsext/ls.go index 2c46416f28a2777ddc9092883686c8a3461a9f7d..4282ac5c6218bcd148d3265acf8a63747586b23b 100644 --- a/internal/fsext/ls.go +++ b/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 { diff --git a/internal/lsp/watcher/global_watcher.go b/internal/lsp/watcher/global_watcher.go index c9aa4b3a26e42fe9a9e2c86834147828534c70fc..e8786888ff5888fecff2a199b9215b4e3867352f 100644 --- a/internal/lsp/watcher/global_watcher.go +++ b/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)