jesseduffield / jesseduffield/lazygit
Extend the existing filter syntax in the Files view with support for negated terms
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
### Is your feature request related to a problem? Please describe.
Navigating the **Files** view can become noisy when there are files you intentionally do not want to see.
For example, I work primarily with .NET repositories that use `packages.lock.json`. These files can sometimes be modified even when no package versions have meaningfully changed, for example because of differences in locally resolved package metadata/cache state.
In those cases I still want Git/LazyGit to report the files as modified, but I would like to temporarily exclude them from the **Files** view so I can focus on the other changes.
LazyGit currently allows filtering files by text, but as far as I can tell there is no equivalent way to exclude matching files.
For example, I would like to be able to enter:
```text
!packages.lock.json
```
to show all changed files except `packages.lock.json`.
### Describe the solution you'd like
Extend the existing filter syntax in the **Files** view with support for negated terms.
For example:
```text
!packages.lock.json
```
would exclude files whose path contains `packages.lock.json`.
It would also be useful if positive and negative terms could be combined:
```text
src !packages.lock.json
```
meaning: show files matching `src`, but exclude anything matching `packages.lock.json`.
This would complement the existing substring/fuzzy filtering without requiring full glob or regex support.
### Describe alternatives you've considered
I considered implementing this using a custom command, but it becomes difficult to reproduce the behavior of the built-in Files filter cleanly.
A custom command can manipulate or inspect Git state, but what I want here is purely a temporary UI filter. I do not want to modify Git's index, mark files as `assume-unchanged`/`skip-worktree`, or otherwise hide the changes from Git itself.
The files should remain modified and available in LazyGit; I only want to temporarily remove matching entries from the current Files view.
### Additional context
I think exclusion would also be useful beyond `.NET` lock files. Generated files, snapshots, formatting-only changes, or other frequently modified files can make it harder to focus on a smaller set of relevant changes.
A simple `!` convention would fit naturally alongside the existing Files filtering behavior and cover most of these cases without adding more complex glob/regex syntax.
I have no real background in Go, but something like below (napkin code):
```go
func FindSubstringsFrom(pattern string, data fuzzy.Source) fuzzy.Matches {
terms := strings.Fields(pattern)
result := fuzzy.Matches{}
outer:
for i := range data.Len() {
s := data.String(i)
for _, term := range terms {
if strings.HasPrefix(term, "!") && len(term) > 1 {
if CaseAwareContains(s, term[1:]) {
continue outer
}
} else if !CaseAwareContains(s, term) {
continue outer
}
}
result = append(result, fuzzy.Match{
Str: s,
Index: i,
})
}
return result
}
```
Contributor guide
Research direction
Start with the existing filter implementation used by the Files view and compare its behavior with the proposed FindSubstringsFrom logic. Verify that positive terms still work, !term excludes matching paths, and combined positive and negative terms show only the intended files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100