Search code examples
luaneovimluajit

Where does Neovim's Lua List type come from?


Edit

This question was very misguided - the feature I'm referring to is from vimscript, not Lua.

Original question

In Neovim's Lua, in addition to normal table objects, you can create List objects like so:

x = [1, 2, 3]

The documentation for lists is fairly straightforward. However, it doesn't seem like 'standard' Lua supports any such syntax, to wit, my Lua 5.4.6 REPL yields an error:

> x = [1, 2, 3]
stdin:1: unexpected symbol near '['

NB, Neovim ships with Lua 5.1, with LuaJIT additionally available on common platforms.

Neovim also loads many utility functions by default in addition to the Lua standard library. This seems straightforward enough to me.

My question then is, if Neovim ships with 'vanilla' Lua/LuaJIT and only adds additional modules/functions, where does this special syntax come from? Or, if there are standard ways of implementing special syntax like this, where can I find the documentation for how to do so?


Solution

  • The content you referred to isn't Lua code; it's actually a Vim script. You can find at the top of the URL you provided: https://neovim.io/doc/user/usr_41.html#41.8

           VIM USER MANUAL - by Bram Moolenaar
                    Write a Vim script