hydra.nvim
hydra.nvim copied to clipboard
Cannot use `_` as a head
It appears that a single _ character cannot be used as a head.
Example:
hydra({
config = {
exit = true,
},
name = "Change case",
mode = "n",
body = "gyc",
heads = {
{"_", function() require("textcase").operator("to_snake_case") end },
{"-", function() require("textcase").operator("to_dash_case") end },
{ "<Esc>", nil, { exit = true } },
},
})
... fails, as soon as gyc is typed, an error is shown:
E5108: Error executing lua: ...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:648: attempt to index a nil value
stack traceback:
...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:648: in function '_make_hint_buffer'
...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:482: in function '_show_hint'
...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:424: in function '_enter'
...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:212: in function <...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.
lua:212>
Changing it to this:
hydra({
config = {
exit = true,
},
name = "Change case",
mode = "n",
body = "gyc",
heads = {
{"x", function() require("textcase").operator("to_snake_case") end },
{"-", function() require("textcase").operator("to_dash_case") end },
{ "<Esc>", nil, { exit = true } },
},
})
works (x and - can now be used as expected as heads).
Thanks for your hard work on this great plugin!
Actually, I suspect this might be an auto-hint generation issue. The same bug occurs if _ is anywhere in the desc attached to a head.
I seem to be able to use _ as one of my hydra heads. However, I get a runtime error when I try to create a hint table for it.
Workaround is to set desc = false for that head and won't try to add it to the hint.