### NotebookNavigator Setup Configuration Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/README.md Configures the plugin's behavior for cell markers, hydra key activations, REPL integration, and highlighting. Defaults apply to unspecified options; requires compatible REPL like iron.nvim and commenting plugin. Inputs are a Lua table passed to setup(); outputs customized plugin functionality with no direct returns. ```lua { -- Code cell marker. Cells start with the marker and end either at the beginning -- of the next cell or at the end of the file. -- By default, uses language-specific double percent comments like `# %%`. -- This can be overridden for each language with this setting. cell_markers = { -- python = "# %%", }, -- If not `nil` the keymap defined in the string will activate the hydra head. -- If you don't want to use hydra you don't need to install it either. activate_hydra_keys = nil, -- If `true` a hint panel will be shown when the hydra head is active. If `false` -- you get a minimalistic hint on the command line. show_hydra_hint = true, -- Mappings while the hydra head is active. -- Any of the mappings can be set to "nil", the string! Not the value! to unamp it hydra_keys = { comment = "c", run = "X", run_and_move = "x", move_up = "k", move_down = "j", add_cell_before = "a", add_cell_after = "b", }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim, -- "molten" for molten-nvim or "auto" which checks which of the above are -- installed repl_provider = "auto", -- Syntax based highlighting. If you don't want to install mini.hipattners or -- enjoy a more minimalistic look syntax_highlight = false, -- (Optional) for use with `mini.hipatterns` to highlight cell markers cell_highlight_group = "Folded", } ``` -------------------------------- ### Lazy.nvim Installation and Configuration for Notebook Navigator (Lua) Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/README.md This Lua snippet shows how to install and configure the Notebook Navigator plugin using the lazy.nvim package manager. It includes keybindings for cell navigation and execution, as well as specifying plugin dependencies. ```lua { "GCBallesteros/NotebookNavigator.nvim", keys = { { "]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()\n" }, { "x", "lua require('notebook-navigator').run_and_move()\n" }, }, dependencies = { "echasnovski/mini.comment", "hkupty/iron.nvim", -- repl provider -- "akinsho/toggleterm.nvim", -- alternative repl provider -- "benlubas/molten-nvim", -- alternative repl provider "anuvyklack/hydra.nvim", }, event = "VeryLazy", config = function() local nn = require "notebook-navigator" nn.setup({ activate_hydra_keys = "h" }) end, } ``` -------------------------------- ### Setup Notebook Navigator with Hydra Mode (Lua) Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Configures Notebook Navigator to use Hydra mode for cell operations. It sets the key to activate Hydra mode and defines specific keybindings for various actions within Hydra. This setup enables a more efficient workflow by reducing the need for repeated key presses. ```lua local nn = require("notebook-navigator") -- Setup with Hydra mode activated by h nn.setup({ activate_hydra_keys = "h", show_hydra_hint = true, hydra_keys = { comment = "c", run = "X", run_and_move = "x", move_up = "k", move_down = "j", add_cell_before = "a", add_cell_after = "b", split_cell = "s", } }) ``` -------------------------------- ### Python Code Cells Example Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/README.md Demonstrates the structure of code cells within a Python script using special comment markers (e.g., '# %%') to delineate distinct code blocks. ```python print("Cell 1") # %% print("This is cell 2!") # %% print("This is the last cell!") ``` -------------------------------- ### Setup Notebook Navigator with lazy.nvim Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Initialize the Notebook Navigator plugin with custom configuration settings. Requires dependencies like mini.comment, iron.nvim, and hydra.nvim. Configures cell markers for different languages, hydra keybindings, and REPL provider settings. ```lua { "GCBallesteros/NotebookNavigator.nvim", keys = { { "]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()" }, { "x", "lua require('notebook-navigator').run_and_move()" }, }, dependencies = { "echasnovski/mini.comment", "hkupty/iron.nvim", "anuvyklack/hydra.nvim", }, event = "VeryLazy", config = function() local nn = require "notebook-navigator" nn.setup({ activate_hydra_keys = "h", show_hydra_hint = true, cell_markers = { python = "# %%", lua = "-- %%", }, hydra_keys = { comment = "c", run = "X", run_and_move = "x", move_up = "k", move_down = "j", add_cell_before = "a", add_cell_after = "b", split_cell = "s", }, repl_provider = "auto", syntax_highlight = false, cell_highlight_group = "Folded", }) end, } ``` -------------------------------- ### Execute all code cells in buffer Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Execute all code cells in the current buffer sequentially from start to finish. Useful for running entire scripts or notebooks at once. Accepts optional REPL arguments for specifying execution terminal. ```lua local nn = require("notebook-navigator") -- Run entire file nn.run_all_cells() -- Run entire file with specific terminal nn.run_all_cells({ id = 3 }) -- Example keybinding vim.keymap.set("n", "xa", function() require("notebook-navigator").run_all_cells() end, { desc = "Run all cells" }) ``` -------------------------------- ### Notebook Navigator Default Configuration in Lua Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/doc/NotebookNavigator.txt The default configuration table for notebooknavigator.nvim defines cell markers using language-specific comments, hydra key mappings for cell operations, REPL provider selection, and highlighting options. It supports customization for languages like Python and integrates with plugins such as iron.nvim or toggleterm.nvim. Inputs are table overrides; outputs integrate the config into the plugin setup, with limitations on unsupported REPLs if not auto-detected. ```lua M.config = { -- Code cell marker. Cells start with the marker and end either at the beginning -- of the next cell or at the end of the file. -- By default, uses language-specific double percent comments like `# %%`. -- This can be overridden for each language with this setting. cell_markers = { -- python = "# %%", }, -- If not `nil` the keymap defined in the string will activate the hydra head activate_hydra_keys = nil, -- If `true` a hint panel will be shown when the hydra head is active show_hydra_hint = true, -- Mappings while the hydra head is active. hydra_keys = { comment = "c", run = "X", run_and_move = "x", move_up = "k", move_down = "j", add_cell_before = "a", add_cell_after = "b", split_cell = "s", }, -- The repl plugin with which to interface -- Current options: "iron" for iron.nvim, "toggleterm" for toggleterm.nvim, -- "molten" for molten-nvim or "auto" which checks which of the above are -- installed repl_provider = "auto", -- Syntax based highlighting. If you don't want to install mini.hipattners or -- enjoy a more minimalistic look syntax_highlight = false, -- (Optional) for use with `mini.hipatterns` to highlight cell markers cell_highlight_group = "Folded", } ``` ```lua require('notebooknavigator').setup({}) ``` -------------------------------- ### Comment Cell in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Toggles comments for all lines within the current code cell. This functionality relies on either the 'mini.comment' or 'comment.nvim' plugins being installed and configured. It simplifies the process of commenting out or uncommenting entire code blocks. ```lua local nn = require("notebook-navigator") -- Comment/uncomment all lines in current cell nn.comment_cell() -- Example keybinding vim.keymap.set("n", "cc", function() require("notebook-navigator").comment_cell() end, { desc = "Comment cell" }) -- Requires either mini.comment or comment.nvim to be installed ``` -------------------------------- ### mini.hipatterns Highlighter Specification in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Offers a highlighter specification for mini.hipatterns to visually distinguish cell markers. This integration helps in clearly identifying the boundaries of code cells within a file, improving navigation and code structure perception. It uses configured highlight groups for visual cues. ```lua -- Setup mini.hipatterns with cell marker highlighting { "echasnovski/mini.hipatterns", event = "VeryLazy", dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" return { highlighters = { cells = nn.minihipatterns_spec } } end, } -- Cell markers like "# %%" will be highlighted with a decorative line -- and the configured highlight group (default: "Folded") ``` -------------------------------- ### Enabling Cell Highlighting with mini.hipatterns (Lua) Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/README.md Configures the mini.hipatterns plugin to provide syntax highlighting for code cells managed by Notebook Navigator. This Lua code snippet adds a custom highlighter spec to mini.hipatterns. ```lua return { "echasnovski/mini.hipatterns", event = "VeryLazy", dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" local opts = { highlighters = { cells = nn.minihipatterns_spec } } return opts end, } ``` -------------------------------- ### mini.ai Textobject Specification in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Provides a textobject specification for use with the mini.ai plugin, enabling operations like delete, yank, and visual selection on code cells. The specification allows defining text objects for entire cells or just their content, simplifying complex text manipulations. ```lua -- Setup mini.ai with notebook cell textobject { "echasnovski/mini.ai", event = "VeryLazy", dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" return { custom_textobjects = { h = nn.miniai_spec -- 'h' for cell textobject } } end, } -- After setup, use these commands: -- dah - delete cell including marker -- dih - delete cell content only -- yah - yank entire cell with marker -- yih - yank cell content only -- vah - visually select entire cell -- vih - visually select cell content -- cih - change cell content -- Example: Delete current cell with marker -- (in normal mode, type): dah -- Example: Yank cell content without marker -- (in normal mode, type): yih ``` -------------------------------- ### Execute cell and move to next Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Execute the current cell and automatically move cursor to the next cell. Creates a new cell at the end of the buffer if currently at the last cell, mimicking Jupyter notebook behavior. Accepts optional REPL arguments for terminal configuration. ```lua local nn = require("notebook-navigator") -- Run current cell and move to next nn.run_and_move() -- Run and move with custom REPL settings nn.run_and_move({ id = 1, trim_spaces = false }) -- Example keybinding for run and advance workflow vim.keymap.set("n", "x", function() require("notebook-navigator").run_and_move() end, { desc = "Run cell and move to next" }) -- This function automatically: -- 1. Executes current cell code -- 2. Moves to next cell marker -- 3. Creates new cell if at end of file (Jupyter-like behavior) ``` -------------------------------- ### Integrating Code Cell Text Object with mini.ai (Lua) Source: https://github.com/gcballesteros/notebooknavigator.nvim/blob/main/README.md Adds a custom text object for code cells to the mini.ai plugin, enabling advanced text manipulation. This Lua configuration snippet integrates Notebook Navigator's cell specification into mini.ai. ```lua return { "echasnovski/mini.ai", event = "VeryLazy", dependencies = { "GCBallesteros/NotebookNavigator.nvim" }, opts = function() local nn = require "notebook-navigator" local opts = { custom_textobjects = { h = nn.miniai_spec } } return opts end, } ``` -------------------------------- ### Execute current code cell Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Send the code in the current cell to the configured REPL provider for execution. Accepts optional REPL arguments for specifying terminal ID and trimming whitespace. Returns execution status information. ```lua local nn = require("notebook-navigator") -- Run current cell with default settings nn.run_cell() -- Run cell with custom REPL arguments for toggleterm nn.run_cell({ id = 2, -- Use terminal with ID 2 trim_spaces = true -- Trim leading/trailing whitespace }) -- Example keybinding to run cell vim.keymap.set("n", "X", function() require("notebook-navigator").run_cell() end, { desc = "Run current cell" }) -- Example: Run cell in specific terminal vim.keymap.set("n", "X2", function() require("notebook-navigator").run_cell({ id = 2 }) end, { desc = "Run cell in terminal 2" }) ``` -------------------------------- ### Run Cells Below in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Executes the current code cell and all subsequent cells in the buffer. It can be called with default arguments or a custom REPL configuration. This function is useful for batch execution of code blocks and is often mapped to a keybinding for convenience. ```lua local nn = require("notebook-navigator") -- Run current and all cells below nn.run_cells_below() -- With custom REPL configuration nn.run_cells_below({ id = 1, trim_spaces = true }) -- Example keybinding vim.keymap.set("n", "xb", function() require("notebook-navigator").run_cells_below() end, { desc = "Run cells below" }) ``` -------------------------------- ### Navigate between code cells Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Move cursor between code cells in the buffer using cell markers. The function accepts a direction parameter ('d' for down/next, 'u' for up/previous) and returns boundary status. Can be used with keybindings for convenient navigation. ```lua local nn = require("notebook-navigator") -- Move to the next cell (down) nn.move_cell("d") -- Move to the previous cell (up) nn.move_cell("u") -- Check if at boundary local result = nn.move_cell("d") if result == "last" then print("Already at the last cell") elseif result == "first" then print("Already at the first cell") end -- Example keybinding setup vim.keymap.set("n", "]h", function() require("notebook-navigator").move_cell("d") end, { desc = "Move to next cell" }) vim.keymap.set("n", "[h", function() require("notebook-navigator").move_cell("u") end, { desc = "Move to previous cell" }) ``` -------------------------------- ### Disable specific Hydra keys in Notebook Navigator (Lua) Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Demonstrates how to disable specific keybindings within Notebook Navigator's Hydra mode. By setting a keybinding to the string "nil", that particular action will no longer be available when Hydra mode is active, allowing for customization of the modal interface. ```lua -- Disable specific hydra keys by setting to "nil" string nn.setup({ activate_hydra_keys = "h", hydra_keys = { comment = "c", run = "X", run_and_move = "x", move_up = "k", move_down = "j", add_cell_before = "nil", -- Disabled add_cell_after = "nil", -- Disabled split_cell = "s", } }) ``` -------------------------------- ### Split Cell in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Splits the current cell at the cursor's position by inserting a cell marker. This is useful for dividing a large cell into smaller, more focused sections, improving code organization and readability. It is often configured with a keybinding. ```lua local nn = require("notebook-navigator") -- Split cell at current cursor position nn.split_cell() -- Example keybinding vim.keymap.set("n", "cs", function() require("notebook-navigator").split_cell() end, { desc = "Split cell" }) -- Before: Cell with 10 lines, cursor on line 5 -- After: Two cells (lines 1-4 and lines 6-10), cursor on line 6 ``` -------------------------------- ### Add Cell Above/Below in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Inserts a new cell marker either above or below the current cell and moves the cursor to the newly created cell. These functions are essential for structuring code into distinct, manageable blocks and are commonly bound to keyboard shortcuts. ```lua local nn = require("notebook-navigator") -- Add cell marker above current cell nn.add_cell_above() -- Add cell marker below current cell nn.add_cell_below() -- Example keybindings vim.keymap.set("n", "ca", function() require("notebook-navigator").add_cell_above() end, { desc = "Add cell above" }) vim.keymap.set("n", "cb", function() require("notebook-navigator").add_cell_below() end, { desc = "Add cell below" }) -- Creates a cell marker like "# %%" (Python) or "-- %%" (Lua) -- depending on the filetype ``` -------------------------------- ### Swap Cell with Adjacent in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Swaps the current cell with the cell directly above or below it. This function aids in rearranging code blocks efficiently within a file. The direction is specified by 'u' for up or 'd' for down, and it's typically bound to keyboard shortcuts. ```lua local nn = require("notebook-navigator") -- Swap current cell with cell below nn.swap_cell("d") -- Swap current cell with cell above nn.swap_cell("u") -- Example keybindings vim.keymap.set("n", "cj", function() require("notebook-navigator").swap_cell("d") end, { desc = "Swap cell down" }) vim.keymap.set("n", "ck", function() require("notebook-navigator").swap_cell("u") end, { desc = "Swap cell up" }) ``` -------------------------------- ### Merge Cell with Adjacent in Lua Source: https://context7.com/gcballesteros/notebooknavigator.nvim/llms.txt Merges the current cell with an adjacent cell (above or below) by removing the cell marker that separates them. This operation is useful for consolidating smaller cells into larger logical units. The direction is controlled by 'u' for up or 'd' for down. ```lua local nn = require("notebook-navigator") -- Merge with cell below nn.merge_cell("d") -- Merge with cell above nn.merge_cell("u") -- Example keybindings vim.keymap.set("n", "cmj", function() require("notebook-navigator").merge_cell("d") end, { desc = "Merge with cell below" }) vim.keymap.set("n", "cmk", function() require("notebook-navigator").merge_cell("u") end, { desc = "Merge with cell above" }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.