nvim/lua/custom/user/ipython_utils.lua
Jeremie Fraeys 6c762c436a
Some checks failed
Luacheck / luacheck (push) Failing after 4s
StyLua / stylua (push) Failing after 2s
fix: endx typo in lsp-servers.lua
2026-02-08 15:08:04 -05:00

26 lines
755 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