gitsigns.nvim icon indicating copy to clipboard operation
gitsigns.nvim copied to clipboard

Allowing count in next / prev hunk keymaps

Open Bekaboo opened this issue 1 year ago • 0 comments

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 avatar May 08 '23 01:05 Bekaboo