anuvyklack / hydra.nvim

Create custom submodes and menus
1.03k stars 24 forks source link

Is it possible to override automated hint generation with custom icons for commands? #54

Open miversen33 opened 2 years ago

miversen33 commented 2 years ago

The title may not be completely clear, so below is an example of a series of Heads I want on a hydra

{"<Left>",  cmd "lua require('smart-splits').resize_left()",  {desc = "Resize Pane/Window Left", silent = true}},
{"<Right>", cmd "lua require('smart-splits').resize_right()", {desc = "Resize Pane/Window Right", silent = true}},
{"<Up>",    cmd "lua require('smart-splits').resize_up()",    {desc = "Resize Pane/Window Up", silent = true}},
{"<Down>",  cmd "lua require('smart-splits').resize_down()",  {desc = "Resize Pane/Window Down", silent = true}},

The hint for this is required (as far as I can tell) to be

hint = [[
_<Left>_: Resize Window Left _<Right>_: Resize Window Right _<Up>_: Resize Window Up _<Down>_: Resize Window Down
]]

IMO, I should be able to put whatever I want as the key command to press instead of being forced to enter the above. As an example, I would like to replace _<Left>_ with _⬅_ but any deviation from _<Left>_ gives the following error

E5108: Error executing lua: ...e/pack/packer/start/hydra.nvim/lua/hydra/hint/window.lua:221: [Hydra] docsting error, head "⬅" does not exist
stack traceback:
        [C]: in function 'error'
        ...e/pack/packer/start/hydra.nvim/lua/hydra/hint/window.lua:221: in function '_make_buffer'
        ...e/pack/packer/start/hydra.nvim/lua/hydra/hint/window.lua:107: in function 'show'
        ...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:501: in function '_enter'
        ...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:255: in function <...vim/site/pack/packer/start/hydra.nvim/lua/hydra/init.lua:254>

Which is true. But if I dont care, this shouldn't stop me. Is there a way to make the docstring not care that the head I provided in the hint doesn't match the head I have? Especially as I am also providing the description in the hint?

miversen33 commented 2 years ago

Reading documentation is apparently hard. This is called out (sorta) here

To highlight a key, just wrap it in underscores. Note that the key must belong to one of the heads. The key will be highlighted with the color that is appropriate to the behavior of the key, i.e. if the key will make the hydra exit, the color will be blue.

Simply removing the _ wrapping allows this to work (albeit without the nice color coating)

anuvyklack commented 2 years ago

I get what you want, I will see what can be done, but not right now.