NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.64k stars 218 forks source link

Can't unmap "u" key in status #1314

Open kitallen23 opened 1 month ago

kitallen23 commented 1 month ago

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,
        }
    }
})
CKolkey commented 1 month ago

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

kitallen23 commented 1 month ago

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 commented 1 month ago

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).

titaniumtraveler commented 1 month ago

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",
},
Aerex commented 1 month ago

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"
}