neogit icon indicating copy to clipboard operation
neogit copied to clipboard

Can't unmap "u" key in status

Open kitallen23 opened this issue 1 year ago • 5 comments

Description

Hi there. I've always struggled with the keymaps in neogit, but I've found a way. However after a recent update, I am unable to use neogit effectively as I can't map (or unmap) the "u" key.

For context, I'm a strange person and I have custom navigation keys. In my case 'u' happens to be my up key.

If anyone knows a workaround, I'd love to hear it.

Neovim version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202

Operating system and version

macOS 14.1.1

Steps to reproduce

  1. Use the minimal config
  2. Open the status window, observe the error

Expected behavior

Status window should open.

Actual behavior

Error executing Lua callback: ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:103: table index is nil
stack traceback:
        ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:103: in function 'open'
        /Users/kit/.local/share/nvim/lazy/neogit/lua/neogit.lua:120: in function 'open_status_buffer'
        /Users/kit/.local/share/nvim/lazy/neogit/lua/neogit.lua:192: in function 'open'
        /Users/kit/.local/share/nvim/lazy/neogit/plugin/neogit.lua:5: in function </Users/kit/.local/share/nvim/lazy/neogit/plugin/neogit.lua:3>

Minimal config

require("neogit").setup({
    mappings = {
        status = {
            ["u"] = false,
        }
    }
})

kitallen23 avatar May 21 '24 15:05 kitallen23

For now, you need to remap the function bound to u. Just setting it to false will not work.

CKolkey avatar May 21 '24 21:05 CKolkey

From memory, I wasn't able to rebind it either. I'll try that when I'm back at my pc later though. However I'm not sure that rebinding it would help in my case?

kitallen23 avatar May 22 '24 04:05 kitallen23

Just tested; you were correct that it seems as though it can be remapped, but it cannot be unmapped. My use case is still broken though (remapping doesn't help in my case).

kitallen23 avatar May 22 '24 07:05 kitallen23

I have the same problem and further more remapping ["<c-s>"] = "SplitOpen", doesn't work and results in a similar error:

E5108: Error executing lua: ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:146: table index is nil
stack traceback:
        ...hare/nvim/lazy/neogit/lua/neogit/buffers/status/init.lua:146: in function 'open'
        $HOME/.local/share/nvim/lazy/neogit/lua/neogit.lua:120: in function 'open_status_buffer'
        $HOME/.local/share/nvim/lazy/neogit/lua/neogit.lua:192: in function 'open'
        $HOME/.config/nvim/lua/custom/plugins/neogit.lua:33: in function <$HOME/.config/nvim/lua/custom/plugins/neogit.lua:32>

(The stacktrace is slightly different that's why I'm posting it here.)

Here the full mappings.status config (with a few things commented out because the unmapping doesn't work.)

status = {
  -- ["1"] = false,
  -- ["2"] = false,
  -- ["3"] = false,
  -- ["4"] = false,

  ["<Leader>1"] = "Depth1",
  ["<Leader>2"] = "Depth2",
  ["<Leader>3"] = "Depth3",
  ["<Leader>4"] = "Depth4",

  -- ["<c-x>"] = false,
  ["<c-s>"] = "SplitOpen",
},

titaniumtraveler avatar May 23 '24 23:05 titaniumtraveler

I think you will need to remap the action to something similar to what @CKolkey mentioned.

For now, you need to remap the function bound to u. Just setting it to false will not work.

For example,

status = {
      ["<c-s>"] = "SplitOpen",
      ["<c-S>"] = "StageAll"
}

Aerex avatar May 30 '24 16:05 Aerex