Quarto runner and iron not using the same repl instance #188
-
Quarto runner opens up a new repl instance when using What I have tried:
Currently my Iron setup looks like: iron.setup({
config = {
scratch_repl = true,
repl_definition = {
python = {
command = { "ipython", "--no-autoindent" },
},
r = {
command = { "radian" },
},
quarto = {
command = { "ipython", "--no-autoindent" },
block_dividers = {
"```{python}",
"```{r}",
"```",
},
},
},
repl_open_cmd = view.split.vertical.botright("40%"),
},
fts = {
quarto = {
block = {
start = "^```%b{}",
stop = "^```%s*$",
strip_start = true,
strip_stop = true,
},
},
}, and my after/ftplugin/quarto.lua looks like: ```lua
-- Insert code chunk keybindings
vim.keymap.set("n", "<leader>qir", "<Esc>O```{r}<Esc>o```<Esc>O", { desc = "[I]nsert [R] chunk" })
vim.keymap.set("n", "<leader>qip", "<Esc>O```{python}<Esc>o```<Esc>O", { desc = "[I]nsert [P]ython chunk" })
vim.keymap.set("n", "<leader>qij", "<Esc>O```{julia}<Esc>o```<Esc>O", { desc = "[I]nsert [J]ulia chunk" })
vim.keymap.set("n", "<leader>qic", "<Esc>O```<Esc>o```<Esc>O", { desc = "[I]nsert [C]ode chunk" })
require("otter").activate()
require("quarto").activate()
-- Doesn't work with iron
-- vim.keymap.set("n", "<leader>pQ", "<cmd>QuartoPreview<cr>", { desc = "[P]review" })
-- vim.keymap.set("n", "<leader>qR", "<cmd>QuartoRender<cr>", { desc = "[R]ender" })
-- -- Set the plugin/keymaps up to provide slime with code to run
-- local runner = require("quarto.runner")
-- vim.keymap.set("n", "<localleader>tb", runner.run_cell, { desc = "[r]un [c]ell", silent = true })
-- vim.keymap.set("n", "<localleader>qra", runner.run_above, { desc = "[r]un cell and [a]bove", silent = true })
-- vim.keymap.set("n", "<localleader>qrb", runner.run_below, { desc = "[r]un cell and [b]elow", silent = true })
-- vim.keymap.set("n", "<localleader>tf", runner.run_all, { desc = "[r]un [A]ll cells", silent = true })
-- vim.keymap.set("n", "<localleader>tl", runner.run_line, { desc = "[r]un [l]ine", silent = true })
-- vim.keymap.set("v", "<localleader>qrr", runner.run_range, { desc = "run visual [r]ange", silent = true })
-- vim.keymap.set("n", "<localleader>tF", function()
-- runner.run_all(true)
-- end, { desc = "[R]un [A]ll cells of all languages", silent = true } The normal plugins/quarto.lua looks like: return {
{
"quarto-dev/quarto-nvim",
ft = { "quarto", "markdown", "rmd", "qmd" },
dependencies = { "nvim-telescope/telescope.nvim", "jmbuhr/otter.nvim" }, -- optional
config = function()
-- initialize the plugin
require("quarto").setup({
codeRunner = {
enabled = true,
default_method = "iron",
},
languages = { "r,", "python", "bash", "html" },
})
end,
}, Is there an easier way to connect the repl opened by quarto.runner as the currently active repl such that I don't have to write custom functionsor override) in I have tried to create a function for Any responses are much appreciated. Thx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Got it working after a few more hours. -- Insert code chunk keybindings
vim.keymap.set("n", "<leader>qir", "<Esc>O```{r}<Esc>o```<Esc>O", { desc = "[I]nsert [R] chunk" })
vim.keymap.set("n", "<leader>qip", "<Esc>O```{python}<Esc>o```<Esc>O", { desc = "[I]nsert [P]ython chunk" })
vim.keymap.set("n", "<leader>qij", "<Esc>O```{julia}<Esc>o```<Esc>O", { desc = "[I]nsert [J]ulia chunk" })
vim.keymap.set("n", "<leader>qic", "<Esc>O```<Esc>o```<Esc>O", { desc = "[I]nsert [C]ode chunk" })
require("otter").activate()
require("quarto").activate()
-- Preview stuff
vim.keymap.set("n", "<leader>pQ", "<cmd>QuartoPreview<cr>", { desc = "[P]review" })
vim.keymap.set("n", "<leader>qR", "<cmd>QuartoRender<cr>", { desc = "[R]ender" })
-- Syncs current repl instance which avoids using quarto.runner
local keeper = require("otter.keeper")
vim.keymap.set("n", "<localleader>tb", function()
lines = keeper.get_language_lines_around_cursor()
require("iron.core").send(nil, lines)
end) I haven't figured out how to do it with |
Beta Was this translation helpful? Give feedback.
Got it working after a few more hours.
Otter has a function
get_lines_around_cursor()
which excludes the quarto fences which allows the code to run.My after/ftplugin/quarto.lua looks like this now: