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

Allowing count in next / prev hunk keymaps #793

Closed
Bekaboo opened this issue May 8, 2023 · 1 comment
Closed

Allowing count in next / prev hunk keymaps #793

Bekaboo opened this issue May 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Bekaboo
Copy link

Bekaboo commented May 8, 2023

Is your feature request related to a problem? Please describe.

According to the documentation, users can map ]c and [c to navigate to next/previous hunk, but currently there's no way to use a count as a prefix before these keymaps.

Describe the solution you'd like

Ideally users should be able to navigate to next/previous [count] hunks by using [count] ]c or [count] [c.

This can be achieved by passing an option count to next_hunk() or prev_hunk().

Describe alternatives you've considered
N/A

Additional context

What I have tried is mapping ]c to

    vim.keymap.set({ 'n', 'x' }, ']c', function()
      if vim.wo.diff then
        return ']c'
      end
      for _ = 1, vim.v.count1 do
        gs.next_hunk()
      end
      return '<Ignore>'
    end, { expr = true })

or

    vim.keymap.set({ 'n', 'x' }, ']c', function()
      if vim.wo.diff then
        return ']c'
      end
      local count = vim.v.count1
      vim.schedule(function()
        for _ = 1, count do
          gs.next_hunk()
        end
      end)
      return '<Ignore>'
    end, { expr = true })

and none of them works.

@Bekaboo Bekaboo added the enhancement New feature or request label May 8, 2023
@lewis6991
Copy link
Owner

Done in #976

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

No branches or pull requests

2 participants