diff --git a/lua/config/plugins/iron.lua b/lua/config/plugins/iron.lua index 3c4ae22..1b30fa5 100644 --- a/lua/config/plugins/iron.lua +++ b/lua/config/plugins/iron.lua @@ -22,7 +22,7 @@ return { }, -- How the repl window will be displayed -- See below for more information - repl_open_cmd = require('iron.view').split.below(80), + repl_open_cmd = 'belowright 20split' --require('iron.view').split.below(80), }, -- Iron doesn't set keymaps by default anymore. -- You can set them here or manually add keymaps to the functions in iron.core diff --git a/lua/custom/functions.lua b/lua/custom/functions.lua index 8442554..40f69f0 100644 --- a/lua/custom/functions.lua +++ b/lua/custom/functions.lua @@ -23,11 +23,29 @@ vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, { command = "set filetype=r" }) +local function IronQuiteSend(opts) + -- Get the current filetype to send to the appropriate REPL + local ft = vim.bo.filetype + + -- Concatenate all arguments passed to the command + local command = table.concat(opts.fargs, " ") + + -- Send the command to the REPL + require('iron.core').send(ft, command) +end + +-- Create the primary command in Neovim +vim.api.nvim_create_user_command('IronQuiteSend', IronQuiteSend, { + nargs = '+', -- Allows for multiple arguments +}) + + + -- Map wd to send devtools::document command in R vim.api.nvim_create_autocmd("FileType", { pattern = "r", callback = function() - vim.api.nvim_set_keymap('n', 'wd', ':RSend devtools::document("' .. DevtoolsPath() .. '")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'wd', ':IronQuiteSend devtools::document("' .. DevtoolsPath() .. '")', { noremap = true, silent = true }) end }) @@ -35,14 +53,16 @@ vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", { pattern = "r", callback = function() - vim.api.nvim_set_keymap('n', 'wi', ':RSend devtools::install("' .. DevtoolsPath() .. '", quick = TRUE, keepSource=TRUE, upgrade = "never")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'wi', ':IronQuiteSend devtools::install("' .. DevtoolsPath() .. '", upgrade = "never")', { noremap = true, silent = true }) end }) vim.api.nvim_create_autocmd("FileType", { pattern = "r", callback = function() - vim.api.nvim_set_keymap('n', 'i', ':RSend install.packages("")', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'i', ':IronQuiteSend install.packages("")', { noremap = true, silent = true }) end }) + +