szymonmaszke / vimpyter

Edit your Jupyter notebooks in Vim/Neovim
MIT License
333 stars 17 forks source link

Buffer variables not defined in call from autocmd #11

Closed ExpectationMax closed 6 years ago

ExpectationMax commented 6 years ago

Somehow buffer variables do not seem to be defined for me when the vimpyter commands are called using autocmd.

I get the following error:

"/var/folders/5w/yrpfs68d73b0xsk17kgh8zx4005f61/T//test.ipynb" 8L, 79C written
Error detected while processing function vimpyter#updateNotebook[41]..<SNR>73_updateNotebookNeovim:
line   11:
E121: Undefined variable: b:proxy_file
E116: Invalid arguments for function jobstart
E15: Invalid expression: jobstart( 'notedown --from markdown --to notebook ' . b:proxy_file . ' > ' . b:original_file, {  'on_exit': function('s:updateSuccessNeovim') })
Press ENTER or type command to continue

Nevertheless everything works if I call vimpyter#updateNotebook manually:

:call vimpyter#updateNotebook()
Updated source notebook

Also a simple test using the following script does not work for me:

augroup VimpyterAutoCommands
autocmd!
augroup END
autocmd BufReadPost *.ipynb call vimpyter#createView()
autocmd BufWritePost *.ipynb echo b:proxy_file

results in

"/var/folders/5w/yrpfs68d73b0xsk17kgh8zx4005f61/T//test.ipynb" 8L, 79C written
Error detected while processing BufWritePost Auto commands for "*.ipynb":
E121: Undefined variable: b:proxy_file
E15: Invalid expression: b:proxy_file

Am I missing something? I am using neovim with the following version and options

NVIM v0.2.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallt
hrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/config -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/inclu
de -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/src/nvim/auto -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/include
Compiled by brew@HighSierra.local

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.2.2_1/share/nvim"
szymonmaszke commented 6 years ago

Have you changed any vimpyter's options like different view location? Does the error persist using minimal .vimrc (using only this plugin)?

ExpectationMax commented 6 years ago

Interestingly, I found the cause of the problems. The buffer variables are solely not defined if NERDTree is open in the same window. Feel free to close this issue, if you have any idea what could cause this behaviour further help would be appreciated though...

szymonmaszke commented 6 years ago

It could be connected to the fact that editing .ipynb files actually open new buffer in /tmp (deletes original buffer and opens this one). Not sure about the interaction with NERDTree as I haven't been running this plugin for ages.

Closing as it's not vimpyter related and I'm not sure what else could be the cause.