neovim / pynvim

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

feat: Ex command `:py=` evaluate and print python expression #548

Closed wookayin closed 7 months ago

wookayin commented 8 months ago

The Ex command :py, :python, :py3, etc. can evaluate the line as an expression rather than a statement if the line starts with =, just like :lua=.

:py= <expr> is equivalent as :py print(<expr>).

:py3= sys.version_info[:3]
:python3 =pynvim.__version__

TODO

Developer note:

should be merged (or rebased) after #547 to avoid conflicts (Merged)

justinmk commented 7 months ago

How to document into /doc/if_pyth.txt (neovim core)? The feature would require pynvim 0.5.0 (or devel).

Better to get it in there asap. One more motivation for doing a pynvim release :)

wookayin commented 7 months ago

Hmm now I think we may want to use repr(...) to print. For example, python3= "foo" might print 'foo' instead of foo only. Will think about it in any subsequent PRs....

Need to make the behavior consistent with https://github.com/neovim/neovim/issues/25379