GCBallesteros / jupytext.nvim

Jupyter notebooks on neovim powered by Jupytext
66 stars 14 forks source link

JupytextFileWrittenPost User autocommand #8

Closed benlubas closed 6 months ago

benlubas commented 6 months ago

I'm trying to automatically export output chunks from molten to a jupyter notebook on file write. Unfortunately it seems like the BufWritePost autocmd event doesn't get called when BufWriteCmd is used (same with FileWrite version of those events). So in order to do this I need to fire a user autocmd from the write_to_ipynb function.

Is this something you would except a PR for? It's a one line change and I think minimally impactful.

GCBallesteros commented 6 months ago

Unfortunately it seems like the BufWritePost autocmd event doesn't get called when BufWriteCmd is used

I have been bitten by this before. Yes, it looks like after a xxxxCmd event is catched, most, if not all, of the remaining xxxx events don't get triggered. This is for instance the reason for this line. The catcher of the xxxxCmd is passed on the responsability for all of it (apparently) although the docs are not very explicit about it except for the "writing" autocmds. The docs have this to say:

When there is a matching "*Cmd" autocommand, it is assumed it will do the
writing.  No further writing is done and the other events are not triggered.

If it is the case, then it's my responsability to call the events and the current behaviour is buggy and should be fixed. Happy to receive a PR for this! Thanks!

benlubas commented 6 months ago

Okay so seems like we should just fire the events ourselves. I can open a PR