diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-08 10:39:51 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-08 10:39:51 +0200 |
| commit | d5b13224737a9f66c3d5113a885603b32867d740 (patch) | |
| tree | d482cc965a65be22604800fe6772279c52961b99 /internal/hexailsp/run.go | |
| parent | bd698b257a548d835fbc2675ff5be5e1a69ff229 (diff) | |
add gitignore-aware file filtering for LSP completions and code actionsv0.18.0
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/hexailsp/run.go')
| -rw-r--r-- | internal/hexailsp/run.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/hexailsp/run.go b/internal/hexailsp/run.go index e2aaf9d..18f5aa5 100644 --- a/internal/hexailsp/run.go +++ b/internal/hexailsp/run.go @@ -10,6 +10,7 @@ import ( "time" "codeberg.org/snonux/hexai/internal/appconfig" + "codeberg.org/snonux/hexai/internal/ignore" "codeberg.org/snonux/hexai/internal/llm" "codeberg.org/snonux/hexai/internal/logging" "codeberg.org/snonux/hexai/internal/lsp" @@ -66,10 +67,15 @@ func RunWithFactory(logPath string, configPath string, stdin io.Reader, stdout i client = buildClientIfNil(cfg, client) factory = ensureFactory(factory) + // Create gitignore-aware file checker for LSP filtering + gitRoot := appconfig.FindGitRoot() + useGI := cfg.IgnoreGitignore == nil || *cfg.IgnoreGitignore + ignoreChecker := ignore.New(gitRoot, useGI, cfg.IgnoreExtraPatterns) + store := runtimeconfig.New(cfg) logContext := strings.TrimSpace(logPath) != "" loadOpts := appconfig.LoadOptions{ConfigPath: strings.TrimSpace(configPath)} - opts := makeServerOptions(cfg, logContext, client, loadOpts) + opts := makeServerOptions(cfg, logContext, client, loadOpts, ignoreChecker) opts.ConfigLoadOptions = loadOpts opts.ConfigStore = store server := factory(stdin, stdout, logger, opts) @@ -83,7 +89,10 @@ func RunWithFactory(logPath string, configPath string, stdin io.Reader, stdout i if newClient := buildClientIfNil(updated, nil); newClient != nil { client = newClient } - opts := makeServerOptions(updated, logContext, client, loadOpts) + // Update ignore checker patterns on config hot-reload + useGI := updated.IgnoreGitignore == nil || *updated.IgnoreGitignore + ignoreChecker.Update(useGI, updated.IgnoreExtraPatterns) + opts := makeServerOptions(updated, logContext, client, loadOpts, ignoreChecker) opts.ConfigStore = store configurable.ApplyOptions(opts) }) @@ -156,7 +165,7 @@ func ensureFactory(factory ServerFactory) ServerFactory { } } -func makeServerOptions(cfg appconfig.App, logContext bool, client llm.Client, loadOpts appconfig.LoadOptions) lsp.ServerOptions { +func makeServerOptions(cfg appconfig.App, logContext bool, client llm.Client, loadOpts appconfig.LoadOptions, ignoreChecker *ignore.Checker) lsp.ServerOptions { // Map custom actions from appconfig to lsp type var customs []lsp.CustomAction if len(cfg.CustomActions) > 0 { @@ -214,5 +223,6 @@ func makeServerOptions(cfg appconfig.App, logContext bool, client llm.Client, lo PromptSimplifySystem: cfg.PromptCodeActionSimplifySystem, PromptSimplifyUser: cfg.PromptCodeActionSimplifyUser, CustomActions: customs, + IgnoreChecker: ignoreChecker, } } |
