From 4ff933aeba4dd699173df226107b9ad1df660d2b Mon Sep 17 00:00:00 2001 From: Alejandro Rodriguez Date: Mon, 25 Nov 2024 14:09:34 +0100 Subject: [PATCH 1/4] added hydra heads for merging and swapping cells --- lua/notebook-navigator/init.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lua/notebook-navigator/init.lua b/lua/notebook-navigator/init.lua index 797d291..c9c3dcb 100644 --- a/lua/notebook-navigator/init.lua +++ b/lua/notebook-navigator/init.lua @@ -207,6 +207,34 @@ local function activate_hydra(config) M.split_cell, { desc = "Split cell", nowait = true }, }, + { + config.hydra_keys.swap_up, + function() + M.swap_cell "u" + end, + { desc = "Swap with cell above", nowait = true }, + }, + { + config.hydra_keys.swap_down, + function() + M.swap_cell "d" + end, + { desc = "Swap with cell below", nowait = true }, + }, + { + config.hydra_keys.merge_up, + function() + M.merge_cell "u" + end, + { desc = "Merge with cell above", nowait = true }, + }, + { + config.hydra_keys.merge_down, + function() + M.merge_cell "d" + end, + { desc = "Merge with cell below", nowait = true }, + }, { "q", nil, { exit = true, nowait = true, desc = "exit" } }, { "", nil, { exit = true, nowait = true, desc = "exit" } }, } @@ -263,6 +291,10 @@ M.config = { add_cell_before = "a", add_cell_after = "b", split_cell = "s", + swap_up = "nil", + swap_down = "nil", + merge_up = "nil", + merge_down = "nil", }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim, From 0c234ce75ed3295fce70a45a827c8710d122da2f Mon Sep 17 00:00:00 2001 From: Alejandro Rodriguez Date: Mon, 25 Nov 2024 14:11:19 +0100 Subject: [PATCH 2/4] docs for new hydra heads --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4d43af8..53bc737 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,12 @@ Any options that are not specified when calling `setup` will take on their defau move_down = "j", add_cell_before = "a", add_cell_after = "b", + split = "s", + swap_up = "nil", + swap_down = "nil", + merge_up = "nil", + merge_down = "nil", + }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim, From 10e4335a04366b7d94eff122cfffd5347b2a28a2 Mon Sep 17 00:00:00 2001 From: Alejandro Rodriguez Date: Fri, 29 Nov 2024 15:57:27 +0100 Subject: [PATCH 3/4] added yank_cell and delete_cell hydra keys --- lua/notebook-navigator/init.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lua/notebook-navigator/init.lua b/lua/notebook-navigator/init.lua index c9c3dcb..a138ed4 100644 --- a/lua/notebook-navigator/init.lua +++ b/lua/notebook-navigator/init.lua @@ -235,6 +235,32 @@ local function activate_hydra(config) end, { desc = "Merge with cell below", nowait = true }, }, + { + config.hydra_keys.yank_cell, + function() + local success, miniai = pcall(require, "mini.ai") + if success then + miniai.select_textobject("a", M.config.cell_textobject_key) + vim.cmd "normal! y" + else + vim.notify "mini.ai required to yank cell" + end + end, + { desc = "Delete cell", nowait = true }, + }, + { + config.hydra_keys.delete_cell, + function() + local success, miniai = pcall(require, "mini.ai") + if success then + miniai.select_textobject("a", M.config.cell_textobject_key) + vim.cmd "normal! d" + else + vim.notify "mini.ai required to delete cell" + end + end, + { desc = "Delete cell", nowait = true }, + }, { "q", nil, { exit = true, nowait = true, desc = "exit" } }, { "", nil, { exit = true, nowait = true, desc = "exit" } }, } @@ -295,6 +321,8 @@ M.config = { swap_down = "nil", merge_up = "nil", merge_down = "nil", + delete_cell = "nil", + yank_cell = "nil", }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim, @@ -305,6 +333,9 @@ M.config = { syntax_highlight = false, -- (Optional) for use with `mini.hipatterns` to highlight cell markers cell_highlight_group = "Folded", + -- (Optional) for use with `mini.ai: key passed to mini as cell textobject. + -- for example: custom_textobjects = { h = nn.miniai_spec } + cell_textobject_key = "h", } --minidoc_afterlines_end From 7b2070dfd34db136d82451316ed63e29faf90782 Mon Sep 17 00:00:00 2001 From: Alejandro Rodriguez Date: Fri, 29 Nov 2024 16:12:29 +0100 Subject: [PATCH 4/4] added some default keymaps --- lua/notebook-navigator/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/notebook-navigator/init.lua b/lua/notebook-navigator/init.lua index a138ed4..ce07475 100644 --- a/lua/notebook-navigator/init.lua +++ b/lua/notebook-navigator/init.lua @@ -317,12 +317,12 @@ M.config = { add_cell_before = "a", add_cell_after = "b", split_cell = "s", + delete_cell = "d", + yank_cell = "y", + merge_down = "m", + merge_up = "nil", swap_up = "nil", swap_down = "nil", - merge_up = "nil", - merge_down = "nil", - delete_cell = "nil", - yank_cell = "nil", }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim,