Skip to content

next_hunk keymaps permanently override existing keymaps #334

@jannes

Description

@jannes

I am using "]c" and "[c" keymaps for hunk navigation with gitsigns in normal mode. I also set them as CodeDiff keymaps. After using :CodeDiff once to view changes and closing it, my gitsigns keymaps do not work anymore. My expectation would be that CodeDiff does not override them permanently, but only for the duration i'm using CodeDiff.

May be that expectation is unreasonable? If so, is there a workaround to be able to use the same keymaps for both CodeDiff and "normal" normal mode?

My config:

  {
    "esmuellert/codediff.nvim",
    dependencies = { "MunifTanjim/nui.nvim" },
    cmd = "CodeDiff",
    opts = {
      -- Keymaps in diff view
      keymaps = {
        view = {
          quit = "q",                    -- Close diff tab
          toggle_explorer = "<leader>b", -- Toggle explorer visibility (explorer mode only)
          next_hunk = "]c",              -- Jump to next change
          prev_hunk = "[c",              -- Jump to previous change
          next_file = "]f",              -- Next file in explorer/history mode
          prev_file = "[f",              -- Previous file in explorer/history mode
        },
        explorer = {
          toggle_view_mode = "i", -- Toggle between 'list' and 'tree' views
        },
      },
    },
  },

and i'm doing

          map('n', ']c', gitsigns.next_hunk, { desc = 'Git: Next hunk' })
          map('n', '[c', gitsigns.prev_hunk, { desc = 'Git: Previous hunk' })

elsewhere

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions