-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to call user defined hydra #3
Comments
To call hydra you need to press |
I wanted to just open the my custom Hydra popup - it is defined with - invoke_on_body = True option - thus there is no need for head key, right? For reference here is command I try to do - add breakpoint at cursor, run dap connect, and open dap Hydra popup using which-key plugin - all mapped to single mapping: ['<leader>da'] = {
":lua require'dap'.set_breakpoint() require'dap'.run({type='python', request='attach', host='127.0.0.1', port=5678})<CR><Plug>(Layer1_enter)",
'Attach'
}
|
Why can't you place this code in hydras |
Never mind. I can create |
Done in a82bc53. You can use it next way local sample = Hydra({...})
sample:activate() -- activate hydra |
Thanks. This fixed the issue. I will post for reference for other people how to integrate this with which-key plug: local Hydra = require('hydra')
local dap = require'dap'
local hint = [[
_n_: step over _s_: Continue/Start _b_: Breakpoint _K_: Eval
_i_: step into _x_: Quit ^ ^ ^ ^
_o_: step out _X_: Stop ^ ^
_c_: to cursor _C_: Close UI
^
^ ^ _q_: exit
]]
local dap_hydra = Hydra({
hint = hint,
config = {
color = 'pink',
invoke_on_body = true,
hint = {
position = 'bottom',
border = 'rounded'
},
},
name = 'dap',
mode = {'n','x'},
body = '<leader>dh',
heads = {
{ 'n', dap.step_over, { silent = true } },
{ 'i', dap.step_into, { silent = true } },
{ 'o', dap.step_out, { silent = true } },
{ 'c', dap.run_to_cursor, { silent = true } },
{ 's', dap.continue, { silent = true } },
{ 'x', ":lua require'dap'.disconnect({ terminateDebuggee = false })<CR>", {exit=true, silent = true } },
{ 'X', dap.close, { silent = true } },
{ 'C', ":lua require('dapui').close()<cr>:DapVirtualTextForceRefresh<CR>", { silent = true } },
{ 'b', dap.toggle_breakpoint, { silent = true } },
{ 'K', ":lua require('dap.ui.widgets').hover()<CR>", { silent = true } },
{ 'q', nil, { exit = true, nowait = true } },
}
}) Then we can create spawn method for hydra - which will take head as an argument: Hydra.spawn = function(head)
if head == 'dap-hydra' then
dap_hydra:activate()
end
end Finally in your which key config file u can spawn dap hydra like so (auto add breakpoint at cursor, run dap attach, ans finally spawn dap-hydra: ['<leader>da'] = {
function()
require'dap'.set_breakpoint()
require'dap'.run({type='python', request='attach', host='127.0.0.1', port=5678})
require'hydra'.spawn('dap-hydra')
end, 'Attach (localhost, 5678)'} ,
|
Awesome plugin (I was waiting for this for long time - it is the only thing that I wish nvim had from emcas)
What I proper way to call my custom hydra?
In my case I defined it under:
<leader>dh
But calling
:normal <leader>dh
wont work.Maybe we could get additional option for Hydra({ reference = xyz })
if we call - require'hydra'.xyz() from cmd or lua this would open user defined hydra?
or something similar way to call user defined hydras would be cool.
The text was updated successfully, but these errors were encountered: