[BUG] LSP tool drops findReferences/goToDefinition results in gitignored paths; respectGitignore: false has no effect
What's wrong
The LSP tool filters findReferences and goToDefinition results that sit in gitignored
paths. incomingCalls and hover for the same symbol do return those locations, so the language
server (gopls) has indexed them. The filtering happens in Claude Code. SettingrespectGitignore: false makes no difference.
This matters for umbrella workspaces where each service is a nested git clone listed in the
parent's .gitignore. In that layout, findReferences reports a function with real callers as
having none (measured: 1 reference returned vs 5 real ones). An "unused" verdict like that can
lead to deleting live code.
Repro (minimal Go module)
go.mod module example.com/fx
lib/lib.go package lib; func F() {}
visible/a.go package visible; import "example.com/fx/lib"; func A() { lib.F() }
hidden/b.go package hidden; import "example.com/fx/lib"; func B() { lib.F() }
| setup | findReferences on F | goToDefinition from a call | incomingCalls on F |
|---|---|---|---|
| nothing ignored | 3 (lib, visible, hidden) | lib/lib.go:3:6 | — |
| .gitignore: /hidden/ | 2: hidden/b.go missing | — | 2, includes hidden/b.go |
| .gitignore: /lib/ | lib/lib.go missing | "No definition found" | — |
| /lib/ + respectGitignore: false | same as above | same | — |
Expected
LSP results match what the server returns. At minimum, respectGitignore: false should turn the
filter off. If the filter is intentional, its output should say how many results were filtered
out, because a silently shortened reference list reads as fact.
Workaround
Use incomingCalls (unfiltered), or run gopls references <file>:<line>:<col> from a shell.
Environment
Claude Code 2.1.296 · macOS (Darwin 25.5) · gopls through the gopls LSP plugin
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗