Commit graph

51 commits

Author SHA1 Message Date
Folke Lemaitre
118648ce93
feat(picker.git_diff): added staged flag 2025-10-29 15:30:58 +01:00
Folke Lemaitre
d343714bc6
refactor(picker.git): use ctx:git_root() where needed 2025-10-28 08:55:13 +01:00
Folke Lemaitre
3049ad8beb
feat(picker.diff): moved git_diff finder to separate file so it can be re-used + made it more robust. Closes #2366 2025-10-28 08:47:18 +01:00
Folke Lemaitre
f2f05e5cff
refactor(picker.proc): ctx:opts() to pass custom options between finders 2025-10-28 08:45:02 +01:00
Folke Lemaitre
7964f040bf
feat(picker.git_diff): add base option to show diff against a merge base. Useful to see changes on a branch/PR 2025-10-23 09:25:56 +02:00
Jakub F. Bortlík
57fbda70d6
feat(picker): allow configuring pathspec for git grep (#2311)
## 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'  },
    },
```
2025-10-22 06:33:33 +02:00
Folke Lemaitre
c9fa6f7b07
feat(picker): added live support to git_log, which uses -S (pickaxe) to search. Closes #1544 2025-10-21 17:49:13 +02:00
Folke Lemaitre
5782b5cda0
feat(git): allow configuring extra git args and git cmd args for all git sources. See #2178 2025-10-21 17:17:14 +02:00
Anthony Qiu
2cf864aaa1
feat(picker): add author field to git log (#2295)
## 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>
2025-10-21 16:38:24 +02:00
hungpt-a8e
2aee35d059
feat(picker.git): allow passing extra args to git log command for file renames (#1964)
Some checks are pending
CI / ci (push) Waiting to run
## 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`.
2025-10-21 09:20:27 +02:00
Iordanis Petkakis
7502e77803
fix(picker.git): add ignorecase for git_grep (#1629)
## 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. -->
2025-10-21 08:38:26 +02:00
Aaron Weisberg
a012f394c9
fix(picker.git_diff): use absolute path when adding buffer to avoid duplicates (#1819)
## 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>
2025-10-20 16:03:03 +02:00
Folke Lemaitre
259cb01d7d
style: format 2025-10-20 15:58:58 +02:00
Daniel Danner
93f43ca10f
fix(git): set diff.noprefix=false for git diff to ensure correct format (#2174)
## 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. -->
2025-10-20 15:54:26 +02:00
Folke Lemaitre
3d695ab7d0
feat(picker.git): added all option to also list remote branched for git_branches. Closes #1465 2025-03-01 09:48:31 +01:00
Folke Lemaitre
bc902f7032
feat(compat): added svim, a compatibility layer for Neovim. Closes #1321 2025-02-20 06:59:44 +01:00
Folke Lemaitre
92786c5b03
feat(picker.git_diff): use the diff previewer for git_diff so that delta can be used. See #1302 2025-02-19 16:56:40 +01:00
Imron Gamidli
8c1166165b
feat(git_log): add author filter (#1091)
## 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>
2025-02-18 21:12:31 +01:00
Pedro Pombeiro
4d46574b24
feat(picker.git): allow passing extra args to other git pickers (#1205)
## 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>
2025-02-18 21:07:50 +01:00
Folke Lemaitre
c114a0da1a
fix(picker.git): correct root dir for git log 2025-02-15 12:06:25 +01:00
Folke Lemaitre
2e284e23d9
fix(picker.git): apply args to git, and not git grep. 2025-02-15 10:36:38 +01:00
Folke Lemaitre
9c436cb273
fix(picker.git): properly handle file renames for git log. Closes #1154 2025-02-15 08:06:07 +01:00
Folke Lemaitre
7122a03fdf
feat(picker.git): allow passing extra args to git grep. Closes #1184 2025-02-15 07:13:41 +01:00
Folke Lemaitre
93ad23a0ab
fix(picker.git): handle git status renames. Closes #1003 2025-02-08 10:45:17 +01:00
Folke Lemaitre
e9e2e6976e
fix(picker.git): account for deleted files in git diff. Closes #1001 2025-02-08 07:12:31 +01:00
Folke Lemaitre
2dc901634b
feat(picker): added git_grep picker. Closes #986 2025-02-07 10:41:38 +01:00
Folke Lemaitre
8c6c54e26a
ci: auto generate picker function types 2025-02-05 07:44:26 +01:00
Folke Lemaitre
8e0dfd2856
fix(git): use nul char as separator for git status 2025-02-04 19:08:38 +01:00
Folke Lemaitre
85e1b343b0
feat(explorer): add hl groups for ignored / hidden files. Closes #887 2025-02-03 11:37:14 +01:00
Folke Lemaitre
5cae48d93c
feat(explorer): added git status. Closes #817 2025-01-31 19:08:32 +01:00
Folke Lemaitre
d76d9aaaf2
fix(git): basic support for git work trees 2025-01-30 23:37:50 +01:00
Folke Lemaitre
e960010496
fix(picker.git): better stash pattern. Closes #775 2025-01-29 00:07:58 +01:00
Folke Lemaitre
7da5d953f9
style(picker.git): luals annotations 2025-01-28 16:32:19 +01:00
Folke Lemaitre
3cdebee880
fix(picker.git): default to git root for git_files. Closes #751 2025-01-28 16:29:26 +01:00
Folke Lemaitre
2b15357c25
fix(picker.git): ignore autostash 2025-01-28 16:06:21 +01:00
Folke Lemaitre
bb3db117a4
feat(picker): added git_stash picker. Closes #762 2025-01-28 16:05:30 +01:00
Folke Lemaitre
9c0e2d4362
refactor(picker): pass finder context to transform 2025-01-22 23:49:56 +01:00
Folke Lemaitre
4c2827246a
refactor(picker.proc): make it easier to customize proc finders 2025-01-22 23:49:56 +01:00
Folke Lemaitre
caf20764f1
refactor(picker.finder): function signature of finders changed to fun(opts, ctx) 2025-01-22 23:49:56 +01:00
Folke Lemaitre
2cac6678a9
fix(picker.git): parse all detached states. See #671 2025-01-21 08:42:12 +01:00
Kyle Whliang
390f687431
fix(picker.git_branches): handle detached HEAD (#671)
## 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>
2025-01-20 20:03:38 +01:00
Folke Lemaitre
23a8668ef0
fix(picker.git): --follow only works for git_log_file. Closes #666 2025-01-20 16:04:41 +01:00
Folke Lemaitre
8563dfce68
feat(picker): added git_branches picker. Closes #614 2025-01-19 16:24:35 +01:00
Folke Lemaitre
903431903b
fix(picker.git): git log file/line for a file not in cwd. Fixes #616 2025-01-19 14:22:30 +01:00
Kristijan Husak
43c312dfc1
fix(picker): show all files in git status (#586)
## Description

When new folder is created in a git project, and there are files inside,
git status picker only shows the folder without any preview. Adding
`-uall` to the commands lists them all.

## Related Issue(s)



## Screenshots

Before: 

![screenshot_2025_01_17_15_42_14](https://github.com/user-attachments/assets/e556f563-dc63-472e-9543-bc784e6e1a35)

After: 

![screenshot_2025_01_17_15_43_13](https://github.com/user-attachments/assets/d6b6d715-02fd-4c77-b167-5c62058153dc)
2025-01-17 20:41:13 +01:00
Folke Lemaitre
1481a90aff
fix(picker.git): git_file and git_line should only show diffs including the file. Fixes #522 2025-01-16 23:21:49 +01:00
Folke Lemaitre
de01218d1d
style(picker.git): lua annotations 2025-01-16 09:58:57 +01:00
Anton Kastritskii
cc69043689
feat(picker.git): added git_diff picker for diff hunks (#519)
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>
2025-01-16 09:54:31 +01:00
Folke Lemaitre
a2fb70e8ba
fix(picker.git): use Snacks.git.get_root instead vim.fs.root for backward compatibility 2025-01-15 21:18:52 +01:00
Kristijan Husak
2cc7cf42e9
fix(picker): set correct cwd for git status picker (#505)
## Description

Cwd was wrong for git status picker.

## Related Issue(s)

- Fixes #504
2025-01-15 20:44:04 +01:00