Skip to content

Commit f04c0ad

Browse files
authored
Fixes for Lua 5.2+ (neovim#43)
1 parent af24091 commit f04c0ad

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

nvim/_compat.lua

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Lua 5.1 forward-compatibility layer.
2+
-- For background see https://github.com/neovim/neovim/pull/9280
3+
--
4+
-- Reference the lua-compat-5.2 project for hints:
5+
-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/compat52/mstrict.lua
6+
-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/tests/test.lua
7+
8+
local lua_version = _VERSION:sub(-3)
9+
10+
if lua_version >= "5.2" then
11+
unpack = table.unpack -- luacheck: ignore 121 143
12+
end

nvim/native.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static int pid_wait(lua_State *L) {
1515

1616
static int pid_wait(lua_State *L) {
1717
int status;
18-
pid_t pid = luaL_checkint(L, 1);
18+
pid_t pid = (pid_t)luaL_checkinteger(L, 1);
1919
/* Work around libuv bug that leaves defunct children:
2020
* https://github.com/libuv/libuv/issues/154 */
2121
while (!kill(pid, 0)) waitpid(pid, &status, WNOHANG);

nvim/session.lua

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local coxpcall = require('coxpcall')
22
local uv = require('luv')
33
local MsgpackRpcStream = require('nvim.msgpack_rpc_stream')
4+
require('nvim._compat')
45

56

67
local Session = {}

test/session_spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local SocketStream = require('nvim.socket_stream')
44
local Session = require('nvim.session')
55
local coxpcall = require('coxpcall')
66
local busted = require('busted')
7+
require('nvim._compat')
78

89
local nvim_prog = os.getenv('NVIM_PROG') or 'nvim'
910
local child_session

0 commit comments

Comments
 (0)