nvim/lua/custom/user/ipython_utils.lua
Jeremie Fraeys 02e26b00b7
Some checks are pending
Check Lua Formatting in MyRepo / Stylua Check (push) Waiting to run
chore(nvim): reinitialize with working config
2026-02-07 21:06:45 -05:00

24 lines
745 B
Lua

local M = {}
-- Function to check if an IPython REPL is open in Neovim panes
function M.is_ipython_open()
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(bufnr) and vim.api.nvim_get_option_value('buftype', { buf = bufnr }) == 'terminal' then
if vim.b[bufnr].python_repl == true then
return true
end
-- Get first few lines to check if it's an IPython REPL
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 10, false)
for _, line in ipairs(lines) do
-- Specific checks for IPython
if line:match('IPython') or line:match('In %[%d+%]:') or line:match('In %[') then
return true
end
end
end
end
return false
end
return M