gabenespoli/vim-jupycent

when using fastfold plugin auto trigger fold when open ipynb file

Closed this issue · 6 comments

When open a ipynb, jupycent will change it to py file. Then open that file.
After install fastfold vim will turn ipynb to py file and auto fold that file.

If I open a py file directly no auto fold.

My fastfold setting:

" Konfekt/FastFold
nmap zuz <Plug>(FastFoldUpdate)
let g:fastfold_savehook = 1
let g:fastfold_fold_command_suffixes =  ['x','X','a','A','o','O','c','C']
let g:fastfold_fold_movement_commands = [']z', '[z', 'zj', 'zk']

Seems it's a default behavior?

When opening an ipynb file, vim-jupycent converts it to a py file and then sets various things on that buffer like folding (see here). When you open the py file directly, vim-jupycent isn't called at all, so the folding is not changed.

If you would like to use vim-jupycent's folding for all py files, you could add the lines of code I linked above to ftplugin/python.vim, for example.

When opening an ipynb, another thing that is set on the py file is an autocmd to update the ipynb when you save the py file. If you open the py file directly, this won't be the case, so you will end up with the ipynb and py files not being synced with each other. If you do open the py file directly and edit it, you can update the ipynb by opening the ipynb (vim-jupycent will then open the py file instead, and set folding, as well as link it to the ipynb), and calling JupycentSaveIpynb.

Yeah, I had read that, thanks for your reply!

When opening an ipynb, another thing that is set on the py file is an autocmd to update the ipynb when you save the py file. If you open the py file directly, this won't be the case, so you will end up with the ipynb and py files not being synced with each other.

Hi @gabenespoli What about this situation(not same as quote above): I open a ipynb file named one.ipynb, then I open a py file name two.ipynb, so now there will be 3 files: one.ipynb, one.py, two.py.

And now if I quit Vim, one.py should be removed but it still there!


Update: can't reproduce it 100 percent. But it did happened.

Seems BufUnload on triggered on focus buffer, so if a ipynb corresponding py loaded into a window but is hidden by another file. :q will not trigger function cleanup.

emmm, a plugin do a set hidden setting. Sorry for bother!