Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
12 changes: 12 additions & 0 deletions lua/notebook-navigator/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions lua/notebook-navigator/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down