Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more (complex) pynvim rplugin documentations & examples (packer, configs,...) #520

Open
jeff-dh opened this issue Dec 9, 2022 · 1 comment

Comments

@jeff-dh
Copy link

jeff-dh commented Dec 9, 2022

I want(ed) to write a python neovim plugin and from everything I could find on the internet pynvim and rplugins are the "new-style" of doing it. I know python and spent a few days on lua neovim plugins, so I though it would be pretty straight forward. Getting used to a slightly different api and that's it.

But I spent now half a day trying to find examples and documentation how to actually write a python (pynvim) neovim plugin and my "new plugin" consists of 20 lines from the pynvim documentation, that's pretty frustrating.

I got stuck with the question how to integrate pynvim rplugins into a packer environment. Installation is not the issue, but how do pynvim plugins get setup / configured? How do I call a setup(lua_table_config) (or equivalent) function on a pynvim plugin? Or is there any other way such a plugin is supposed to be configured from within a lua neovim configuration?

I finally started browsing https://github.com/topics/neovim?l=python to find examples (and discarding global vim variables) I finally found a hint that lead me to this proof of concept for a "solution":

config = {
    xyz = 1,
    blablub = true,
    foo = { bar = 'blub'}
}
-- TestFunction is a pynvim decorated rplugin function (from the examples ;)
vim.api.nvim_call_function("TestFunction", {config})

This took me quite a long time to figure this out and I think it would be nice to have somewhere more documentation and examples how the basics (for example configuration) of real world pynvim rplugins are supposed to be designed.

There are some very basic examples and documentation out there but that's pretty much everything I could find. The real world examples I finally could find where mostly so complex that it was pretty hard to get the information I was looking for.

This makes it pretty hard to get into pynvim.

So the bottom line are the following question:

  • how are pynvim rplugins supposed to get configure / setup from a lua environment?
  • are there more examples / documentation for pynvim rplugins that demonstrate how the basics (like configuration) of pynvim plugins are supposed to be designed
  • and if so, why can't I find them......

Thx, I'm looking forward to use pynvim as plugin language for neovim, sounds like a great combination.

@jeff-dh
Copy link
Author

jeff-dh commented Dec 10, 2022

I created the example I was looking for and couldn't find on my own now:

https://github.com/jeff-dh/pynvimExample

It's supposed to be kind of a "getting started" example for pynvim.

I would appreciate any feedback, ideas, opinions from more advanced pynvim users!
Don't be afraid it's only ~100 sloc + ~60 line README.

If you like to reference / use it in the documentation or similar, feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant