Skip to content

Commit 10e4335

Browse files
author
Alejandro Rodriguez
committed
added yank_cell and delete_cell hydra keys
1 parent 0c234ce commit 10e4335

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lua/notebook-navigator/init.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,32 @@ local function activate_hydra(config)
235235
end,
236236
{ desc = "Merge with cell below", nowait = true },
237237
},
238+
{
239+
config.hydra_keys.yank_cell,
240+
function()
241+
local success, miniai = pcall(require, "mini.ai")
242+
if success then
243+
miniai.select_textobject("a", M.config.cell_textobject_key)
244+
vim.cmd "normal! y"
245+
else
246+
vim.notify "mini.ai required to yank cell"
247+
end
248+
end,
249+
{ desc = "Delete cell", nowait = true },
250+
},
251+
{
252+
config.hydra_keys.delete_cell,
253+
function()
254+
local success, miniai = pcall(require, "mini.ai")
255+
if success then
256+
miniai.select_textobject("a", M.config.cell_textobject_key)
257+
vim.cmd "normal! d"
258+
else
259+
vim.notify "mini.ai required to delete cell"
260+
end
261+
end,
262+
{ desc = "Delete cell", nowait = true },
263+
},
238264
{ "q", nil, { exit = true, nowait = true, desc = "exit" } },
239265
{ "<esc>", nil, { exit = true, nowait = true, desc = "exit" } },
240266
}
@@ -295,6 +321,8 @@ M.config = {
295321
swap_down = "nil",
296322
merge_up = "nil",
297323
merge_down = "nil",
324+
delete_cell = "nil",
325+
yank_cell = "nil",
298326
},
299327
-- The repl plugin with which to interface
300328
-- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim,
@@ -305,6 +333,9 @@ M.config = {
305333
syntax_highlight = false,
306334
-- (Optional) for use with `mini.hipatterns` to highlight cell markers
307335
cell_highlight_group = "Folded",
336+
-- (Optional) for use with `mini.ai: key passed to mini as cell textobject.
337+
-- for example: custom_textobjects = { h = nn.miniai_spec }
338+
cell_textobject_key = "h",
308339
}
309340
--minidoc_afterlines_end
310341

0 commit comments

Comments
 (0)