Make Jupynium compatible with non-jupynium (`*.ju.*`) files
vandalt opened this issue · comments
Is your feature request related to a problem? Please describe.
It would be nice to be able to use jupynium.nvim
with "regular" scripts (non-jupynium files e.g. somefile.py
), such as py:precent
scripts from jupytext
. These are relatively common and used across many editors, so supporting them would help make the plugin compatible with more projects.
From what I understand, this is almost supported. I was able to start the server, attach and sync. However, highlighting and keymaps are not available. The py:percent
format is also already supported if the file is a *.ju.*
file.
Describe the solution you'd like
I think making the pattern
, which is currently hardcoded for the keymap and highlighting autocmmand, configurable would solve this. Maybe there could be a main "pattern" option, and have the current command-specific file_pattern
to override?
If the above option (or something else that enables this feature) would be acceptable, I'd be happy to work on a PR.
Describe alternatives you've considered
An alternative would be to automatically rename the file with .ju.{py,r,etc}
suffix when opening it, but it would become cumbersome to specify when this should or should not be done. Another option is to convert to ipynb
with jupytext
, and then to ju.*
with ipynb2jupy
, but this seems like a lot of back-and-forth between file formats.
Sure! The current file_pattern
configures auto-starting server and syncing. This would almost likely be a personal choice and should be configured by users. On the other hand, highlighting and textobjects can be grouped into one file_pattern
configuration because the goal is the same: making other files detected as a jupynium file.
Correct wording would be important here so it's clear what each pattern means. I don't think there needs a global pattern and overrides for commands. I think the auto-starting commands should just have their separate file_pattern, and we just need to be clear what the main pattern does.
We can name this jupynium_file_pattern
and say it adds necessary vim commands (:JupyniumStartAndAttachToServer
etc.), highlighting and keybindings etc.
We can make two defaults for now (jupynium_file_pattern = { "*.ju.*", "*.sync.py" }
) because Jupyter Ascending users may have a lot of sync.py
files.
I just implemented this. Check it out.
This works on my end! Adding ".ipynb" even makes it compatible with files automatically converted by jupytext.vim
. Thank you!
Great it works like that! I hope to implement auto-converting soon, nonetheless.