return { -- 'goerz/jupytext.vim', -- ft = { 'python', 'markdown' }, -- config = function() -- vim.g.jupytext_fmt = 'py:percent' -- vim.g.jupytext_enable = 1 -- vim.g.jupytext_pairing = 1 -- -- local jupytext_bin = vim.fn.exepath('jupytext') -- if jupytext_bin ~= nil and jupytext_bin ~= '' then -- vim.g.jupytext_command = jupytext_bin -- else -- local preferred_python3 = '/opt/homebrew/bin/python3' -- local python3_bin = preferred_python3 -- if vim.fn.executable(preferred_python3) ~= 1 then -- python3_bin = vim.fn.exepath('python3') -- end -- -- if python3_bin ~= nil and python3_bin ~= '' then -- vim.g.jupytext_command = python3_bin .. ' -m jupytext' -- else -- vim.schedule(function() -- vim.notify( -- 'Jupytext: no `jupytext` or `python3` found in PATH. Install jupytext (e.g. `/opt/homebrew/bin/python3 -m pip install --user jupytext`) or set `vim.g.jupytext_command`.', -- vim.log.levels.WARN -- ) -- end) -- end -- end -- -- local jupytext_group = vim.api.nvim_create_augroup('custom_jupytext', { clear = true }) -- -- vim.api.nvim_create_autocmd('BufWritePost', { -- group = jupytext_group, -- pattern = '*.py', -- callback = function() -- local ipynb_file = vim.fn.expand('%:r') .. '.ipynb' -- if vim.fn.filereadable(ipynb_file) == 1 then -- vim.cmd('silent! Jupytext --sync') -- end -- end, -- }) -- -- vim.api.nvim_create_autocmd('BufWritePost', { -- group = jupytext_group, -- pattern = '*.ipynb', -- callback = function() -- local py_file = vim.fn.expand('%:r') .. '.py' -- if vim.fn.filereadable(py_file) == 1 then -- vim.cmd('silent! Jupytext --sync') -- end -- end, -- }) -- -- vim.api.nvim_create_autocmd({ 'BufReadPost', 'BufNewFile' }, { -- group = jupytext_group, -- pattern = '*.ipynb', -- callback = function() -- local py_file = vim.fn.expand('%:r') .. '.py' -- if vim.fn.filereadable(py_file) == 0 then -- vim.cmd('silent! Jupytext --to py:percent') -- end -- -- if vim.fn.filereadable(py_file) == 1 then -- vim.cmd('silent! edit ' .. vim.fn.fnameescape(py_file)) -- end -- end, -- }) -- end, }