nanotee / nvim-lua-guide

A guide to using Lua in Neovim
5.83k stars 220 forks source link

vim.api.nvim_exec() example gives error #85

Closed johnwilmes closed 2 years ago

johnwilmes commented 2 years ago

In neovim 0.5.1, when I execute the example in the vim.api.nvim_exec() section (by pasting that text into a lua script, which I then source), I get the error "E5113: Error while calling lua chunk: tmp.lua:1: Vim(let):E461: Illegal variable name: s:mytext"

It seems that script-local variables (and also script-local functions) are not allowed from nvim_exec, so the "s:" prefixes should be omitted.

nanotee commented 2 years ago

I forgot to mention that script-local variables only work in Neovim 0.6.0 when I updated this section a few days ago, thanks for reminding me!