Closed tzachar closed 3 years ago
ok, a bit hacky, but I came up with the following:
"magma setup
let g:magma_save_path = stdpath("data") .. "/magma/"
function! MyMagmaInit()
setlocal filetype=python
set syntax=python
let l:mangled_fname = expand('%:p') .. '.json'
let l:mangled_fname = substitute(l:mangled_fname, '%', '%%', 'g')
let l:mangled_fname = substitute(l:mangled_fname, '/', '%', 'g')
let l:save_file = g:magma_save_path .. l:mangled_fname
if filereadable(l:save_file)
MagmaLoad
else
MagmaInit python3
endif
endfunction
augroup magma
au! BufRead,BufNewFile *.jupyter call MyMagmaInit()
au! BufWrite *.jupyter MagmaSave
augroup end
Yeah, for now this is what you should indeed do. I think the actual solution here is not to create a new version of MagmaInit/MagmaLoad for this specific scenario, but to create some functions to allow you to easily query things like
We can open a new issue for that.
Sure, that would be helpfull.
Im trying to set up a workflow, where I automatically load magma for *.jupyter files, and get consistent behavior between opening new files and reopening old files. Something like this:
However, Im getting a clash between MagmaInit and MagmaLoad when reopening a file, as MagmaLoad tries to init a second time:
Also, when opening a new file, the MagmaLoad fails gloriously. Any ideas how to solve this? Can we add a way of checking if a file has saved state, reload it id it exists and if not init magma? Maybe a new command, something like: