neovim / pynvim

Python client and plugin host for Nvim
http://pynvim.readthedocs.io/en/latest/
Apache License 2.0
1.48k stars 118 forks source link

python: vim.vars nested dictionary assignment not propagated to vim #456

Closed puremourning closed 3 years ago

puremourning commented 3 years ago
ben@BeniMac2020 vimspector % nvim --version
NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/config -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/src -I/usr/local/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/src/nvim/auto -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/include
Compiled by brew@Catalina

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.4/share/nvim"

Run :checkhealth for more info

Steps to reproduce using nvim -u NORC

py3 import vim
py3 vim.vars[ 'test' ] = {}
py3 vim.vars[ 'test' ][ 'toast' ] = 1

echo g:test.toast

Actual behaviour

Error detected while processing /Users/ben/.vim/bundle/vimspector/nvim_python_dict.vim:
line    5:
E716: Key not present in Dictionary: toast
Press ENTER or type command to continue

Expected behaviour

1

Vim returns 1.

puremourning commented 3 years ago

For the record, the simpler code works, as in:

py3 vim.vars[ 'test' ] = 1

echo g:test
justinmk commented 3 years ago

py3 import vim py3 vim.vars[ 'test' ] = {} py3 vim.vars[ 'test' ][ 'toast' ] = 1

echo g:test.toast

This can't work because the container (map/list) is serialized and copied over RPC. References (bindeval) are not supported.

Duplicate of https://github.com/neovim/neovim/issues/1898

bfredl commented 3 years ago

@puremourning contributions welcome. (I want to work on this, but soo much to do already)