From 31d36c3efd7384931b7bb96b45082d2ef1041671 Mon Sep 17 00:00:00 2001 From: ESSO0428 <92996726+ESSO0428@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:02:43 +0800 Subject: [PATCH 1/7] Update core.lua (add run_cells_above support in core) --- lua/notebook-navigator/core.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/notebook-navigator/core.lua b/lua/notebook-navigator/core.lua index 65e9925..f46f13d 100644 --- a/lua/notebook-navigator/core.lua +++ b/lua/notebook-navigator/core.lua @@ -137,6 +137,18 @@ M.run_all_cells = function(repl_provider, repl_args) return repl(1, buf_length, repl_args) end +M.run_cells_above = function(cell_marker, repl_provider, repl_args) + local start_line = 1 + local cell_object = miniai_spec("i", cell_marker) + + local repl = get_repl(repl_provider) + + if cell_object.from.line > 1 then + local previous_cell_end = cell_object.from.line - 1 + repl(start_line, previous_cell_end, repl_args) + end +end + M.run_cells_below = function(cell_marker, repl_provider, repl_args) local buf_length = vim.api.nvim_buf_line_count(0) local cell_object = miniai_spec("i", cell_marker) From 153b265bd105238e998d94ce126946be1ea5fd6c Mon Sep 17 00:00:00 2001 From: ESSO0428 <92996726+ESSO0428@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:03:51 +0800 Subject: [PATCH 2/7] Update init.lua (add run_cells_above support in init) --- lua/notebook-navigator/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/notebook-navigator/init.lua b/lua/notebook-navigator/init.lua index 1f8637e..e4fca87 100644 --- a/lua/notebook-navigator/init.lua +++ b/lua/notebook-navigator/init.lua @@ -110,6 +110,13 @@ M.run_all_cells = function(repl_args) core.run_all_cells(M.config.repl_provider, repl_args) end +--- Run all cells above the current cell +--- +---@param repl_args table|nil Optional config for the repl. +M.run_cells_above = function(repl_args) + core.run_cells_above(cell_marker(), M.config.repl_provider, repl_args) +end + --- Run all cells below (including current cell) --- ---@param repl_args table|nil Optional config for the repl. @@ -207,7 +214,7 @@ local function activate_hydra(config) M.split_cell, { desc = "Split cell", nowait = true }, }, - { "q", nil, { exit = true, nowait = true, desc = "exit" } }, + { "q", nil, { exit = true, nowait = true, desc = "exit" } }, { "", nil, { exit = true, nowait = true, desc = "exit" } }, } From 67782c6291b7e3cdf679f42d30f5e8803dd3e3c1 Mon Sep 17 00:00:00 2001 From: ESSO0428 <92996726+ESSO0428@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:16:27 +0800 Subject: [PATCH 3/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 95f0f59..def8efa 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ be run (just by smashing `x`) or for less commonly used functionality. ```lua { - "GCBallesteros/NotebookNavigator.nvim", + "ESSO0428/NotebookNavigator.nvim", keys = { { "]h", function() require("notebook-navigator").move_cell "d" end }, { "[h", function() require("notebook-navigator").move_cell "u" end }, @@ -92,7 +92,7 @@ look like: return { "echasnovski/mini.hipatterns", event = "VeryLazy", - dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, + dependencies = { "ESSO0428/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" @@ -116,7 +116,7 @@ meant include the _code cell_ text object then your 'mini.ai' could look like: return { "echasnovski/mini.ai", event = "VeryLazy", - dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, + dependencies = { "ESSO0428/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" From c1a402341e268b2f46177df60c9d1a8ebd5b86e0 Mon Sep 17 00:00:00 2001 From: ESSO0428 <92996726+ESSO0428@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:17:38 +0800 Subject: [PATCH 4/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index def8efa..11b4a57 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ be run (just by smashing `x`) or for less commonly used functionality. { "ESSO0428/NotebookNavigator.nvim", keys = { + { "[e", function() require("notebook-navigator").run_cells_above "" end }, + { "]e", function() require("notebook-navigator").run_cells_below "" end }, { "]h", function() require("notebook-navigator").move_cell "d" end }, { "[h", function() require("notebook-navigator").move_cell "u" end }, { "X", "lua require('notebook-navigator').run_cell()" }, From 8656d7210c9099da58914d5d844028f0c3334bc7 Mon Sep 17 00:00:00 2001 From: ESSO0428 <92996726+ESSO0428@users.noreply.github.com> Date: Fri, 24 May 2024 22:49:13 +0800 Subject: [PATCH 5/7] Update README.md --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 11b4a57..95f0f59 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,8 @@ be run (just by smashing `x`) or for less commonly used functionality. ```lua { - "ESSO0428/NotebookNavigator.nvim", + "GCBallesteros/NotebookNavigator.nvim", keys = { - { "[e", function() require("notebook-navigator").run_cells_above "" end }, - { "]e", function() require("notebook-navigator").run_cells_below "" end }, { "]h", function() require("notebook-navigator").move_cell "d" end }, { "[h", function() require("notebook-navigator").move_cell "u" end }, { "X", "lua require('notebook-navigator').run_cell()" }, @@ -94,7 +92,7 @@ look like: return { "echasnovski/mini.hipatterns", event = "VeryLazy", - dependencies = { "ESSO0428/NotebookNavigator.nvim" }, + dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" @@ -118,7 +116,7 @@ meant include the _code cell_ text object then your 'mini.ai' could look like: return { "echasnovski/mini.ai", event = "VeryLazy", - dependencies = { "ESSO0428/NotebookNavigator.nvim" }, + dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" From 7dc48a269dfc10cf4a6d7135830f5022e200b231 Mon Sep 17 00:00:00 2001 From: Thomas Vandal Date: Tue, 23 Dec 2025 07:56:57 -0500 Subject: [PATCH 6/7] Fix formatting --- lua/notebook-navigator/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/notebook-navigator/init.lua b/lua/notebook-navigator/init.lua index e4fca87..7adb9e1 100644 --- a/lua/notebook-navigator/init.lua +++ b/lua/notebook-navigator/init.lua @@ -214,7 +214,7 @@ local function activate_hydra(config) M.split_cell, { desc = "Split cell", nowait = true }, }, - { "q", nil, { exit = true, nowait = true, desc = "exit" } }, + { "q", nil, { exit = true, nowait = true, desc = "exit" } }, { "", nil, { exit = true, nowait = true, desc = "exit" } }, } From c89784b60868322e7bfbd7eaf03d36f1430897c1 Mon Sep 17 00:00:00 2001 From: Thomas Vandal Date: Tue, 23 Dec 2025 08:04:46 -0500 Subject: [PATCH 7/7] Mention run_cells_above in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 95f0f59..32cfd42 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ provider. below (`dir='d'`). - `run_all_cells(repl_args)`: Run all the file. - `run_cells_below(repl_args)`: Run the current cell and all of the ones below. +- `run_cells_above(repl_args)`: Run the all cells above the current one. - `comment_cell`: Comment the code inside the current cell. - `add_cell_below`: Add a cell marker below the current cell. - `add_cell_after`: Same as above (deprecated).