nvimtools / hydra.nvim

Create custom submodes and menus
MIT License
145 stars 8 forks source link

ensure that Layer:_normalize_input returns non-nil tables #33

Closed edlandm closed 7 months ago

edlandm commented 7 months ago

This prevents a runtime error in when a Hydra is defined that only has heads where exit = true which causes layer_keymaps to be nil. Further on in hydra/layer/init layer_keymaps is assumed to be non-nil.

Reproducing is pretty simple. You can try creating a Hydra like this and it should error without my fix:

require("hydra")({
      mode = "t",
      config = {
        color = "pink",
        buffer = true,
      },
      heads = {
        { "q", function() api.nvim_feedkeys("q", 'i', false) end,
          { desc = "Close", exit_before = true, }, },
      },
    }):activate()

image

miversen33 commented 7 months ago

I've not run into this issue specifically but I did test your branch out and I am not seeing any issues with it. Your code change is super minimal so I think its probably fine :)