From 023ed82e612451caa38ec46106ed9d148ab9a595 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 8 Feb 2026 10:39:51 +0200 Subject: add gitignore-aware file filtering for LSP completions and code actions Files matching .gitignore patterns or user-configured extra patterns are now skipped for completions and code actions. Configurable via [ignore] section in config.toml with gitignore, extra_patterns, and lsp_notify_ignored options. Includes hot-reload support and env var overrides (HEXAI_IGNORE_*). Co-Authored-By: Claude Opus 4.6 --- internal/lsp/handlers_ignore.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/lsp/handlers_ignore.go (limited to 'internal/lsp/handlers_ignore.go') diff --git a/internal/lsp/handlers_ignore.go b/internal/lsp/handlers_ignore.go new file mode 100644 index 0000000..bbd2dfa --- /dev/null +++ b/internal/lsp/handlers_ignore.go @@ -0,0 +1,41 @@ +// Summary: Helpers for gitignore-aware file filtering in LSP handlers. +package lsp + +import ( + "net/url" + "strings" +) + +// isFileIgnored checks whether the file at the given LSP URI should be ignored. +// Returns false when no ignore checker is configured. +func (s *Server) isFileIgnored(uri string) (bool, string) { + if s.ignoreChecker == nil { + return false, "" + } + absPath := uriToPath(uri) + if absPath == "" { + return false, "" + } + return s.ignoreChecker.IsIgnored(absPath) +} + +// ignoreLSPNotifyEnabled returns whether to show "file ignored" completion items +// when a file is ignored. Reads from the IgnoreLSPNotify config field. +func (s *Server) ignoreLSPNotifyEnabled() bool { + s.mu.RLock() + defer s.mu.RUnlock() + return s.cfg.IgnoreLSPNotify == nil || *s.cfg.IgnoreLSPNotify +} + +// uriToPath converts a file:// URI to an absolute file path. +// Returns empty string for non-file URIs. +func uriToPath(uri string) string { + if !strings.HasPrefix(uri, "file://") { + return "" + } + parsed, err := url.Parse(uri) + if err != nil { + return "" + } + return parsed.Path +} -- cgit v1.2.3