False positive: keymap collision warning ignores buffer type

Open Beginner friendly
#565 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
neovim

Research direction

Search the source for the warning text 'are mapped to the same key' to find the keymap validation code. Check how it groups keymaps.explorer.select and keymaps.history.select, since they are scoped to different buffer types. Done when the same key bound in explorer and history no longer triggers the warning, while a real collision within one buffer type still does.

Written by the indexing model from the issue text.

Description

Type/Bug

Setting explorer.select and history.select to the same key (e.g. <space>) triggers the warning:

[codediff] explorer.select, history.select are mapped to the same key <Space>. Only one of them can work; give the others different keys.

But explorer and history are separate buffer types with their own mappings — the keys never actually collide, since only one buffer is active at a time.

Here's my config:

Click to expand
{
    diff = {
      disable_inlay_hints = false,
      hide_merge_artifacts = true,
      jump_to_first_change = false,
      compact = true,
    },
    explorer = {
      initial_focus = 'modified',
      icons = {
        folder_closed = '',
        folder_open = '',
      },
      view_mode = 'tree',
    },
    keymaps = {
      view = {
        quit = '<C-c>',
        toggle_explorer = '`',
        focus_explorer = '~',
        next_hunk = ']g',
        prev_hunk = '[g',
        next_file = '<c-j>',
        prev_file = '<c-k>',
      },
      explorer = {
        select = '<space>',
        toggle_view_mode = 'i',
      },
      history = {
        select = '<space>',
      },
      conflict = {
        accept_incoming = 'gc<', -- Accept incoming (theirs/left) change
        accept_current = 'gc>',  -- Accept current (ours/right) change
        accept_both = 'gcb',
        discard = 'gcx',
        next_conflict = ']x',
        prev_conflict = '[x',
        diffget_incoming = '2do',
        diffget_current = '3do',
      },
    },
  }
Dominant language
Lua
Stars
1.6k
Forks
104
Avg merge
16d 23h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from esmuellert/codediff.nvim

All issues in esmuellert/codediff.nvim

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.