-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug fix: cyclic dependency causing sendline errors #382
Conversation
@ottersome I like your solution solution. I found a slightly different way to do this though that keeps
What are your thoughts? It has been messy trying to edit: Just realized mine has a flaw. If the user does not include a repl definition for python, the |
Hey @nickeisenberg , good to hear from you. May I ask why the preference for consistency with -- common.lua
common.bracketed_paste = function(lines, particularities)
local result = {}
-- ~~~local is_ipython = contains(cmd, "ipython")~~~
lines = remove_empty_lines(lines)
local indent_open = false
for i, line in ipairs(lines) do
if string.match(line, "^%s") ~= nil then
indent_open = true
end
table.insert(result, line)
-- ~~~if is_windows() and not is_ipython or not is_windows() then~~~
if particularities["must_close_indents"] then
if i < #lines and indent_open and string.match(lines[i + 1], "^%s") == nil then
if not python_close_indent_exceptions(lines[i + 1]) then
indent_open = false
table.insert(result, cr)
end
end
end
end
-- ~~~if is_windows() then~~~
if particularities["consider_window_carriage"] then
table.insert(result, "\r\n")
else
table.insert(result, cr)
end
-- So on and so forth.
-- If becomes too long one can add a router that will dispatch line formatting to a specific function according to its "particularity"
return result
end Then in -- python.lua
local bracketed_paste= require("iron.fts.common").bracketed_paste
local python = {}
local is_windows = require("iron.util.os").is_windows
local executable = function(exe)
return vim.api.nvim_call_function("executable", { exe }) == 1
end
local pyversion = executable("python3") and "python3" or "python"
-- Create a map where each value checks for conditions:
local form_particularities = function(cmd)
local particularities = {
["must_close_indents"] = is_windows() and not contains(cmd, "ipython") or not is_windows(),
["consider_windows_carraige"] = is_windows(),
}
return particularities
end
local def = function(cmd)
return {
command = cmd,
format = form_particularities(cmd),
}
end
python.ptipython = def({ "ptipython" })
python.ipython = def({ "ipython", "--no-autoindent" })
python.ptpython = def({ "ptpython" })
python.python = def({ pyversion })
return python This would keep all language-specific behavior within language-specific files and leave |
@ottersome I like that idea. For the meantime I am going to stick with your original PR. Eventually |
@ottersome Hey Luis, I wanted to tell you that I slightly refactored you PR in a way that does not break prior users configs.
|
Ah,I see! Thank you for the refactor. |
Sending a line via
send_line
would prop up errors (see #379). Passingcmd
via an anonymous function wrapper fixes it while avoiding the extrarequire
call.