I am trying to improve a GitHub repository for Neovim called
quangnguyen30192/cmp-nvim-ultisnips
It's a Lua repository that calls another Vim plugin repository, SirVer/ultisnips , a primarily Python-only library.
I basically need to call, in Python, UltiSnips_Manager._snips('completion text here', True))
, and somehow get that list of string data back into Lua.
My plan was to imitate how UltiSnips does this, which is to call the Python object and assign its return value to a global Vim variable and then access that variable later. I just need to adapt the solution to work for Lua.
Here was my naive attempt at using Lua
to call a Python
function and send that data to a Vim
variable so I could access it again, via Lua
vim.exec_python("""
import vim
snippets = UltiSnips_Manager._snips('completion text here', True)
snippet_names = [snipper.trigger for snippet in snippts]
vim.command(\"let g:_allowed_snippets = '%s'\" % snippet_names)
""")
print(vim.g._allowed_snippets)
That doesn't work, because exec_python isn't a real Lua function, as far as I can tell. If there's a way to call Python within Lua in Neovim, could someone please explain how to do that? Or if there's a simpler way to call a Python script that is "known" to Vim and get the data back as a Lua object could someone explain how that could be done?