Spawn and use interactive shells and REPLs from your buffer
- Lua 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| lua/interactive | ||
| plugin | ||
| README.md | ||
interactive.nvim
This plugin enables testing and iterating on scripts by sending code snippets to interactive REPL sessions.
When a window containing a REPL is closed or otherwise hidden (e.g. swapping to a different buffer,) that session will be destroyed.
Commands
:InteractiveStartwill start a new session of Interactive using the default REPL configured for the current buffer's language:InteractiveClosewill close the current session of Interactive owned by the current buffer:InteractiveToggleopens an Interactive session if it does not exist, otherwise closes it:InteractiveSendsend lines to Interactive session, a range can be specified (:xInteractiveSend,:x,yInteractiveSend)
Binds
You will need to specify your own bindings in your configuration. The following sequences are used:
<Plug>InteractiveToggle(normal mode) does the same as:InteractiveToggle<Plug>InteractiveSend(normal mode) sends the current line to the current Interactive session<Plug>InteractiveSend(visual mode) sends all the lines from the current visual selection to the Interactive session
You may map your own sequence to these actions in Lua like so:
-- Map InteractiveToggle to a sequence following Leader key
vim.keymap.set("n", "<Leader>ii", "<Plug>InteractiveToggle")
-- Map InteractiveSend to Alt-Enter
vim.keymap.set("n", "<M-CR>", "<Plug>InteractiveSend")
vim.keymap.set("v", "<M-CR>", "<Plug>InteractiveSend")
Or in VimScript like so:
"Map InteractiveToggle to a sequence following Leader key
nmap <Leader>ii <Plug>InteractiveToggle
"Map InteractiveSend to Alt-Enter
nmap <M-CR> <Plug>InteractiveSend
vmap <M-CR> <Plug>InteractiveSend
Configuration
The following table represents the default settings of Interactive:
{
repls = { -- Table containing language definitions.
fsharp = { -- Name of the language (its 'filetype').
exe = {"dotnet", "fsi"}, -- REPL Executable as a table, each
-- argument as a single string.
terminator = ";;\n", -- If the interpreter requires a specific
-- terminator for input not present in the
-- source file, specify it here.
autoindent_hack = false, -- Some interpreters will autoindent code,
-- this breaks Interactive when sending
-- code which is already indented; enable
-- this to trigger a workaround which
-- eliminates indents before sending each
-- new line.
},
python = {
exe = {"python"},
terminator = "",
autoindent_hack = true,
},
javascript = {
exe = {"node"},
terminator = "",
autoindent_hack = false,
},
lua = {
exe = {"lua"},
terminator = "",
autoindent_hack = false,
}
},
vertical_split = true -- Specify whether the Interactive session should
-- split the current view vertically or
-- horizontally.
}
You may set, modify and override options by calling Interactive's setup function from your package manager.
function()
require("interactive").setup{
repls = {
python = {
exe = {"ipython"},
terminator = "",
autoindent_hack = false
}
}
}
end