Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(builtin.git_diff): new picker for diff hunks #3131

Closed
wants to merge 2 commits into from

Conversation

antonk52
Copy link
Contributor

Description

This PR adds a picker for git diff hunks. The new picker may seem similar to git_status picker at first. However, it allows to view multiple hunks in a single file as separate entries; when a hunk is selected it jumps the cursor to the changes line instead of a first line of a file. You can also supply additinal arguments such as --ignore-all-space which can make hunks seem even more granular and easier to review when navigating via telescope. I have been testing this picker in my configuration for the past few months and think that other telescope users will find this useful.

I understand that at the time of first publishing this PR is in a pretty raw shape as it requires documentation updates and is currently using vim.fn.systemlist instead of an entry maker as entries cannot be inferred from a single line of output. I could not figure out a way to make the way the git diff output is parsed to work similar to how other pickers work. I if you think this is a welcome change I am happy to make appropriate changes to get this PR to a mergeable state.

Demo:

Screen.Recording.2024-05-22.at.01.36.07.mov

Look forward to see what you think about this feature.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Has hunks
    • Make changes in a git repository
    • run :Teelscope git_diff
    • expect to see a picker with diff hunks (multiple entries for single file with multiple hunks)
    • when an entry is selected it jumps to changed lines
  • Clean git repositry
    • run :Teelscope git_diff
    • no picker, error message ""

Configuration:

  • Neovim version (nvim --version): v0.10
  • Operating system and version: macos 14.4

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@jamestrew
Copy link
Contributor

I'm sorry but we're not really accepting any new pickers at the moment. We're kinda struggling with maintaining all the ones we already have. See #1228

I would recommend packaging this as an extension to telescope though. See https://github.com/nvim-telescope/telescope.nvim/blob/c2ce039188e22288449e43b77710036e69a45a70/developers.md#bundling-as-extension

@jamestrew jamestrew closed this May 25, 2024
@nishantpillai5
Copy link

@antonk52 Would love this as an extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants