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
Lua 5.2+ compatbility #9280
Lua 5.2+ compatbility #9280
Conversation
Should we have Do we need a lint check to avoid adding new uses of unpack which aren't compatible? |
What about lua plugin code that is written for nvim+lua5.1 (the officially supported build)? What should we tell the user when such plugins break on this separate nvim+5.2 config? What if someone develops a plugin on nvim+5.2, not knowing the build has been altered, and it break for someone using the official lua5.1/luajit config? An option is just to make it clearer that distros are expected to use lua 5.1 or luajit. We could could make the buildscripts fail if lua 5.2/5.3 is used. Distros can statically link the correct version with nvim, nvim can't hardly be the only software that expects a given lua 5.x version, given all the incompatibilities. |
Though to be less strict, we can still allow external build/generator/test code itself to be run by the distros lua. The issue is with the expectations for people writing runtime plugins. |
Lint does fail currently:
|
I think it is a bad idea. It would make Neovim hard to build for distributions like Fedora which has Lua 5.3 as the default Lua (LuaJIT is available), and not all packages for lua 5.1 are available (and I am neither Fedora user nor maintainer any more). Look at https://build.opensuse.org/package/show/home:mcepl:neovim/neovim |
Again, we could support 5.2/5.3 for the build process, which has the all the dependencies for extra binary lua packages (lpeg etc). But for runtime support only |
The unfortunate part of the Lua ecosystem is that the different Lua versions aren't compatible. This forces distributors to choose a Lua version when they need to compile a program. I'm not sure about Fedora, but I know that Debian's Lua packaging makes it trivial to build modules for multiple Lua versions. However, that doesn't apply to binaries (like vim and nvim). Those need to choose a specific version of Lua, which will then restrict what modules can be used if module upstreams don't target all Lua versions. This problem already exists with Vim since Vim explicitly supports being built against any of the current Lua versions. I think the number of Lua plugins written for Vim is tiny, though, whereas nvim is specifically treating Lua as a first class citizen. The expectation is that there will be a lot more Lua written for nvim. If we allow nvim to be built against any Lua version, then plugin authors need to account for that. However, if we don't allow that, then we potentially make it harder for people to use modules they want. |
As a plugin developer, one of the things I expect is solid foundations to rely on, such as always being 5.1 on runtime. Otherwise I'd need to have multiple different abstraction layers, which is absolutely suboptimal. As a fedora user, I solved the issue of having no default lua-5.1 by using supported out-of-the-tree packages to provide me lua-5.1 and luarocks-5.1. That's a small hurdle, but neovim itself was already packaged correctly, so that was only required for me to write and test plugins. |
Except you really cannot have out-of-the-tree packages for the official neovim, right? |
Why not? nvim with lua 5.1 can load any external |
I didn't have to install lua-5.1 to have neovim. It was already distributed with Lua correctly embedded (IIRC luajit). Don't mix my requirement as a plugin developer with neovim install/usage experience. |
as @jamessan mentioned there is a lint issue. #9280 (comment)
For simple cases that seems reasonable. And maybe for our use case we won't run into many 5.2/5.3-incompatible situations. For example there's no need for Nvim-Lua code to use There is also lua-compat-5.2 or lua-compat-5.3 but those seem risky and may invite more problems than solutions. |
I don't understand this. It is exactly the main construct we use, right? local unpack = table.unpack or unpack I can understand that it may be problematic for a lint because it always expects to fail on at least one branch of the |
@mcepl Maybe the linter simply avoids repeating complaints of the same undefined name |
What I meant is that linters are not fountains of all wisdom, and in this case I don't see anything particularly wrong with what I did. |
I just answered the direct question "why lint complains only here not with every other use of this construct?". I didn't say anything about wisdom, it is just a simple rule to avoid excessive output (but e g gcc will say "further references omitted", so it is clearer). Somewhere it is configured what global names are allowed (nvim already adds some), one would need to add |
The only whitelisted global seems to be |
@bfredl that wasn't against you. I was reacting more to @justinmk who seemed to indicate (in #9280 (comment)), that this cannot be merged unless the lint issues are resolved. |
Well, linter issues have to be resolved, in the sense that the build is not red. If the linter is wrong, the proper resolution is to reconfigure the linter, I don't think anyone is against that. |
@mcepl I see that |
@@ -1,3 +1,5 @@ | |||
require('vim.compat') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to do this implicitly instead. But let's discuss that later.
@@ -38,7 +38,10 @@ set(ENV{SYSTEM_NAME} ${SYSTEM_NAME}) | |||
execute_process( | |||
COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE} | |||
--lua=${LUA_PRG} --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua | |||
--lpath=${BUILD_DIR}/?.lua --lpath=?.lua ${TEST_PATH} | |||
--lpath=${BUILD_DIR}/?.lua | |||
--lpath=${WORKING_DIR}/runtime/lua/?.lua |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a try at sharing code between tests/runtime/core. Maybe we will do it differently, I will have a followup PR for further discussion, after this one.
Related: #8677 cc @KillTheMule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand makefiles, so just a thought: Is ?
recursive, so it also catches runtime/lua/plugin/init.lua
? Also, does the test runner have access to vim.api
? If so, great boon to writing tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's recursive.
Also, does the test runner have access to vim.api? If so, great boon to writing tests!
vim.api
is built-into Nvim so that would not be "shared". The test utilities could spawn nvim
to use its features. We probably should do that, to reduce some of the code in */helpers.lua
.
@mcepl I pushed to your branch. Could you confirm if this works? Then will merge. |
Fedora Rawhide package shows this:
And when I pull out a
I guess, the answer is yes. Note however, that I have actually never run binary out of this package myself, so I would have to find some Fedora machine to test it (and aside from openSUSE machines, I have only some CentOS7 ones here). |
The different Lua versions aren't explicitly API incompatible. There simply are no guarantees about compatibility, so depending on the APIs being used it is possible for one code base to work in all the Lua versions. Then there's the matter that different Lua versions definitely are not ABI compatible, so it's not possible to use compiled C modules that were built against different Lua versions. |
Well, in the world of Linux distributions, you are expected to have rebulit all binary modules from its sources, so it shouldn't be a problem. |
It works, but I have a comment. |
bah, QuickBuild is failing,
Update: QuickBuild doesn't use |
Make the code run both on Lua 5.1 (which is the default for Neovim, and is what LuaJIT provides) and Lua 5.2+.
This is compatibility layer, which makes the code run both on Lua 5.1 (which is the default for Neovim, and it is what LuaJIT provides) and Lua 5.2+.
As mentioned in #7879 (comment)