hydra.nvim icon indicating copy to clipboard operation
hydra.nvim copied to clipboard

Hydra Telescope Heads

Open Allaman opened this issue 3 years ago • 10 comments

Hi,

I have a Hydra mode for my telescope mappings which is as follows:

local Hydra = require("hydra")

local function cmd(command)
  return table.concat({ "<Cmd>", command, "<CR>" })
end

local hint = [[
 _f_: files          _p_: projects
 _t_: live grep      _s_: grep string
 _H_: header         _S_: symbols
 _R_: register       _P_: plugins
 _h_: vim help       _c_: execute command
 _k_: keymaps        _;_: commands history
 _O_: options        _?_: search history
 _/_: search in file _m_: make
 _r_: recently opened files

 ^
 _<Enter>_: Telescope   _q_: Exit
]]

Hydra({
  name = "Telescope",
  hint = hint,
  config = {
    invoke_on_body = true,
    hint = {
      position = "middle",
      border = "rounded",
    },
  },
  mode = "n",
  body = "<Leader>s",
  heads = {
    { "c", cmd("Telescope commands"), { desc = "execute command" } },
    { "f", cmd("Telescope find_files") },
    { "t", cmd("Telescope live_grep") },
    { "h", cmd("Telescope help_tags"), { desc = "vim help" } },
    { "H", cmd("Telescope heading") },
    { "k", cmd("Telescope keymaps") },
    { "O", cmd("Telescope vim_options") },
    { "m", cmd("Telescope make") },
    { "p", cmd("Telescope projects"), { desc = "projects" } },
    { "P", cmd("Telescope packer") },
    { "r", cmd("Telescope oldfiles"), { desc = "recently opened files" } },
    { "R", cmd("Telescope registers") },
    { "s", cmd("Telescope grep_string"), { desc = "Text under cursor" } },
    { "S", cmd("Telescope symbols") },
    { "/", cmd("Telescope current_buffer_fuzzy_find"), { desc = "search in file" } },
    { "?", cmd("Telescope search_history"), { desc = "search history" } },
    { ";", cmd("Telescope command_history"), { desc = "command-line history" } },
    { "<Enter>", cmd("Telescope"), { exit = true, desc = "list all pickers" } },
    { "q", nil, { exit = true, nowait = true } },
  },
})

Since a couple of days whenever I call Telescope via a head Telescope is always started in normal mode despite the following config for telescope:

telescope.setup({
    defaults = {
      initial_mode = "insert",
    }
})    

When starting Telescope via :Telescope live_grep it starts in insert mode as expected.

Thanks

Allaman avatar Sep 19 '22 16:09 Allaman

Yes, I faced this issue too. See 58e7e7ae1c9cc8d587fb6beda4e90a8147069a30

anuvyklack avatar Sep 20 '22 17:09 anuvyklack

Sry, I don't understand your reference? I do not pass additional parameters to Telescope commands so I should not be affected by https://github.com/anuvyklack/hydra.nvim/commit/58e7e7ae1c9cc8d587fb6beda4e90a8147069a3?. I set initial_mode in my telescope configuration itself

Allaman avatar Sep 20 '22 17:09 Allaman

I mean, the problem you are described is due to 58e7e7a commit. But I can't revert it because it fixes another, more important issue.

I will see what I can do more.

anuvyklack avatar Sep 20 '22 17:09 anuvyklack

Thanks for your clarification!

Allaman avatar Sep 20 '22 17:09 Allaman

Hi @anuvyklack, Unfortunately, https://github.com/anuvyklack/hydra.nvim/commit/fa814c478a69d0bc05c3e2cdda34336b7484ea05 is not fixing the issue for me :(

Allaman avatar Sep 21 '22 07:09 Allaman

Can't reproduce. What is the last working commit?

anuvyklack avatar Sep 21 '22 09:09 anuvyklack

Check the telescope branch.

anuvyklack avatar Sep 21 '22 09:09 anuvyklack

ea91aa820a6cecc57bde764bb23612fff26a15de is working and 58e7e7ae1c9cc8d587fb6beda4e90a8147069a30 isn't working anymore. I didn't check commits after 58e7e7ae1c9cc8d587fb6beda4e90a8147069a30.

telescope branch has the same issue.

Maybe helpful: here is my hydra config stuff and here my telescope config.

Allaman avatar Sep 21 '22 09:09 Allaman

I just built my (bloated) Dockerimage and can reproduce the issue there as well

Allaman avatar Sep 21 '22 10:09 Allaman

I currently have hydra pinned to 928855b69f55c7abcaa6594d20968c33ab2317e6 and I did check each commit after that one. Like @Allaman said, https://github.com/anuvyklack/hydra.nvim/commit/58e7e7ae1c9cc8d587fb6beda4e90a8147069a30 is the commit that causes the issue and the telescope branch doesn't fix this issue either

ram02z avatar Sep 24 '22 13:09 ram02z