## Description
This is in place of the rejected PR #2178. Please consider the following
reasons for merging.
This PR adds the possibility to specify pathspec patterns to the `git
grep .... -- <patchspec>` command. This is necessary for ignoring large
git-tracked files (that cannot be added to `.gitignore`) from the git
grep search. git-grepping in some large files with very long lines can
freeze Neovim and make `Snacks.picker.git_grep` completely unusable.
Without this change the picker cannot be configured to use some
pathspecs by default. They can be added dynamically in live mode but
re-typing the same pathspecs every time one needs to use
`Snacks.picker.git_grep` would be silly.
In reply to the [question if cmd_args can be used for
this](https://github.com/folke/snacks.nvim/pull/2178#discussion_r2448762906):
No. The "pathspecs" need to be specified *last* (optionally after `--`).
When configuring Snacks.picker like this:
```lua
sources = {
git_grep = {
cmd_args = { ':!*.min.js', ':!*.min.css', ':!uv.lock' },
},
}
```
then the `cmd_args` are inserted in front of the search pattern and `git
grep` doesn't find anything. The following config can't be used either
because that will cause the [search
pattern](c9fa6f7b07/lua/snacks/picker/source/git.lua (L76))
to be treated as one of the pathspecs.
```lua
git_grep = {
cmd_args = { '--', ':!*.min.js', ':!*.min.css', ':!uv.lock' },
},
```
## Description
Currently in the picker you cant filter git log pickers by author, the
only option to do that right now is to pass it into the opts when you
call it like lua Snacks.picker.git_log({ author="test" }) but most of
the time I would like to filter interactively and also use the field
filtering offered by snacks like file:lua$ and with this new change,
author:test.
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<img width="760" height="842" alt="Screenshot 2025-10-13 at 11 03 28 PM"
src="https://github.com/user-attachments/assets/e57278aa-0fcd-4513-981d-fe8cfe078c64"
/>
<!-- Add screenshots of the changes if applicable. -->
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
Allows passing extra Git arguments (like `--git-dir` or `--work-tree`)
to the rename detection logic inside `M.log` in `picker/source/git.lua`.
Previously, these extra arguments from `opts.args` were applied to the
main `git log` command but ignored during rename detection. This caused
errors or incorrect results when working in non-standard repo setups.
This change uses `git_args(...)` to build the rename detection command,
ensuring consistent argument handling throughout `M.log`.
## Description
Add option for `ignorecase` for `git_grep`
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
Fixes#1627
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
Uses absolute path for setting the cursor
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
Fixes#1818
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
---------
Co-authored-by: Aaron Weisberg <aaron.weisberg@quizlet.com>
## Description
Parsing the output of git diff here depends on its exact format. The
user environment might be set up with diff.noprefix, in which case the
parsing fails, because the `a/` and `b/` prefixes for the paths is
missing. Passing `-c diff.noprefix=false` to the call overrides this.
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
## Description
I was using LazyGit feature to filter git logs by the author,
unfortunately it was missing in snacks picker. Here is my solution to
it. Let me know if you have better suggestion :)
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
This PR builds on
7122a03fdf
to provide a way to pass custom `args` to git command invocations.
An alternative (probably cleaner) way of doing this could be to add an
`args` field to `picker.sources.git`:
```yaml
picker = {
---@class snacks.picker.previewers.Config
previewers = {
git = {
args = git_opts(),
},
},
---@class snacks.picker.sources.Config
sources = {
git = {
args = git_opts(),
},
},
```
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
Fixes#1184
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
Handle [detached
HEAD](https://git-scm.com/docs/git-checkout#_detached_head)
- list: display correct information
- preview: without error notification
- action: checkout the commit that HEAD detached at
<!-- Describe the big picture of your changes to communicate to the
maintainers
why we should accept this pull request. -->
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
- Fixes#672
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
Before:
<img width="1308" alt="image"
src="https://github.com/user-attachments/assets/fad291a3-a730-4a2b-9eb2-4a0edd83d794"
/>
After:
<img width="1038" alt="image"
src="https://github.com/user-attachments/assets/d312579a-e12d-4286-845c-a706d91a6c95"
/>
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
Hi and thank you for the useful plugin!
## Description
I have been exploring the new picker api and got this git diff picker
working which I think can be a nice addition to the existing set of
picker. The key difference from the existing git_status picker is that
it separates each hunk into its own item similar to `git add --patch`
and when you select an item it takes you to the first hunk's line
instead of top of the buffer. Before I put more effort into it I would
like to see if this is a welcome change first.
This implementation can be further extended by allowing to support
additional arguments such as `--staged`, `--ignore-all-space` or both.
A few points on current implementations. I could not get the per line
parsing to work using the
`require("snacks.picker.source.proc").proc(...)` and fell back to
manually parsing the output after the command finished executing. There
are likely many ways to improve it. I have been using it with telescope
for about a year and so far it worked great. I think more people can
benefit from this picker.
## Related Issue(s)
none
## Screenshots
Demo
https://github.com/user-attachments/assets/6cdfa48e-bc29-4194-8430-092fbc5f3dcd
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>