Skip to content

Instantly share code, notes, and snippets.

@mengwangk
Last active June 21, 2023 12:41
Show Gist options
  • Save mengwangk/5bdcf20b17fc565825349c2491495a0d to your computer and use it in GitHub Desktop.
Save mengwangk/5bdcf20b17fc565825349c2491495a0d to your computer and use it in GitHub Desktop.
Neovim PDE - Data Science and Blockchain (Part 2)
local function repl_menu()
local cmd = require("hydra.keymap-util").cmd
local hint = [[
^
_e_: Execute Cell
_i_: Insert Cell
_j_: Next Cell
_k_: Previous Cell
_r_: Insert Markdown Cell
_x_: Delete Cell
^
_s_: Send Motion
_l_: Send Line
_t_: Send Until Cursor
_f_: Send File
^
_R_: Show REPL
_C_: Close REPL
_S_: Restart REPL
_F_: Focus
_H_: Hide
^
_c_: Clear
_L_: Clear Highlight
_<CR>_: ENTER
_I_: Interrupt
^
^ ^ _q_: Quit
]]
return {
name = "REPL",
hint = hint,
config = {
color = "pink",
invoke_on_body = true,
hint = {
border = "rounded",
position = "top-left",
},
},
mode = "n",
body = "<A-n>",
-- stylua: ignore
heads = {
{ "e", execute_cell, desc = "Execute Cell", },
{ "i", insert_code_cell, desc = "Insert Cell", },
{ "j", navigate_cell , desc = "Next Cell", },
{ "k", function() navigate_cell(true) end, desc = "Previous Cell", },
{ "r", insert_markdown_cell, desc = "Insert Markdown Cell", },
{ "x", delete_cell, desc = "Delete Cell", },
{ "s", function() require("iron.core").run_motion("send_motion") end, desc = "Send Motion" },
{ "l", function() require("iron.core").send_line() end, desc = "Send Line" },
{ "t", function() require("iron.core").send_until_cursor() end, desc = "Send Until Cursor" },
{ "f", function() require("iron.core").send_file() end, desc = "Send File" },
{ "L", function() require("iron.marks").clear_hl() end, mode = {"v"}, desc = "Clear Highlight" },
{ "<CR>", function() require("iron.core").send(nil, string.char(13)) end, desc = "ENTER" },
{ "I", function() require("iron.core").send(nil, string.char(03)) end, desc = "Interrupt" },
{ "C", function() require("iron.core").close_repl() end, desc = "Close REPL" },
{ "c", function() require("iron.core").send(nil, string.char(12)) end, desc = "Clear" },
{ "R", cmd("IronRepl"), desc = "REPL" },
{ "S", cmd("IronRestart"), desc = "Restart" },
{ "F", cmd("IronFocus"), desc = "Focus" },
{ "H", cmd("IronHide"), desc = "Hide" },
{ "q", nil, { exit = true, nowait = true, desc = "Exit" } },
},
}
end
...
{
"anuvyklack/hydra.nvim",
opts = {
specs = {
repl = repl_menu,
},
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment