Error when defining python command with a function and using bracketed paste format
Hello. I am using the following config for Python :
python = {
command = function()
if package.loaded["venv-selector"] then
local venv = require("venv-selector")
local venv_path = venv.python()
-- for master branch, use venv.get_active_path()
if venv_path then
return { venv_path }
end
end
return { "python3" }
end,
format = require("iron.fts.common").bracketed_paste_python,
},
But as soon as I send something to the repl, an error occurs. It seems the bracketed_paste_python function calls the contains function in iron.fts.common treating the command as a table, and not a function. It would be nice to handle that case too, with something like this:
if type(cmd) == "function" then
cmd = cmd(meta) -- idk where to find meta though
end
Thanks in advance !
I have the same issue, but this time it is because my command is a string. It is not an error, I use the feature of iron that spawns a bash process when the command argument is a string and not a table with an executable and arguments.
require("iron.core").setup {
config = {
repl_definition = {
python = {
command = "source .venv/bin/activate; ipython; python",
format = require("iron.fts.common").bracketed_paste_python
}
},
}
I't funny that we are both trying to make it org with venv :)
The error seems to come from here: https://github.com/Vigemus/iron.nvim/blob/916538ebf75b8ede8e0feef4f4cd88d5cc82a67e/lua/iron/lowlevel.lua#L158
and then here: https://github.com/Vigemus/iron.nvim/blob/916538ebf75b8ede8e0feef4f4cd88d5cc82a67e/lua/iron/fts/common.lua#L100
Pretty ugly to check manually if command is ipython ...
The is_ipython check is now only used on Windows. Does this help things? I dont have much desire to make things less ugly on Windows as most people use linux or mac.