mirror of
https://github.com/neovim/neovim.git
synced 2025-12-05 22:22:44 +00:00
Merge #9280 'Lua 5.2+ compatbility'
This commit is contained in:
@@ -688,7 +688,7 @@ if(LUACHECK_PRG)
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake)
|
||||
|
||||
add_custom_target(
|
||||
blobcodelint
|
||||
lintbuiltinlua
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
||||
@@ -697,10 +697,21 @@ if(LUACHECK_PRG)
|
||||
-DREAD_GLOBALS=vim
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake
|
||||
)
|
||||
add_custom_target(
|
||||
lintruntimelua
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/runtime/lua
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DREAD_GLOBALS=vim
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake
|
||||
)
|
||||
# TODO(ZyX-I): Run linter for all lua code in src
|
||||
add_custom_target(
|
||||
lualint
|
||||
DEPENDS blobcodelint
|
||||
DEPENDS lintruntimelua
|
||||
DEPENDS lintbuiltinlua
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -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
|
||||
--lpath=?.lua
|
||||
${TEST_PATH}
|
||||
WORKING_DIRECTORY ${WORKING_DIR}
|
||||
ERROR_VARIABLE err
|
||||
RESULT_VARIABLE res
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require('vim.compat')
|
||||
|
||||
local buf_hls = {}
|
||||
|
||||
local function highlight_line(line, linenr)
|
||||
@@ -10,9 +12,9 @@ local function highlight_line(line, linenr)
|
||||
local attr = NONE
|
||||
local byte = 0 -- byte offset
|
||||
|
||||
local function end_attr_hl(attr)
|
||||
local function end_attr_hl(attr_)
|
||||
for i, hl in ipairs(hls) do
|
||||
if hl.attr == attr and hl.final == -1 then
|
||||
if hl.attr == attr_ and hl.final == -1 then
|
||||
hl.final = byte
|
||||
hls[i] = hl
|
||||
end
|
||||
@@ -106,7 +108,7 @@ local function highlight_line(line, linenr)
|
||||
-- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117)
|
||||
local sgr = prev_char:match("^%[([\032-\063]*)m$")
|
||||
if sgr then
|
||||
local match = ''
|
||||
local match
|
||||
while sgr and #sgr > 0 do
|
||||
-- Match against SGR parameters, which may be separated by ';'
|
||||
match, sgr = sgr:match("^(%d*);?(.*)")
|
||||
|
||||
12
runtime/lua/vim/compat.lua
Normal file
12
runtime/lua/vim/compat.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Lua 5.1 forward-compatibility layer.
|
||||
-- For background see https://github.com/neovim/neovim/pull/9280
|
||||
--
|
||||
-- Reference the lua-compat-5.2 project for hints:
|
||||
-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/compat52/mstrict.lua
|
||||
-- https://github.com/keplerproject/lua-compat-5.2/blob/c164c8f339b95451b572d6b4b4d11e944dc7169d/tests/test.lua
|
||||
|
||||
local lua_version = _VERSION:sub(-3)
|
||||
|
||||
if lua_version >= "5.2" then
|
||||
unpack = table.unpack -- luacheck: ignore 121 143
|
||||
end
|
||||
@@ -1,3 +1,4 @@
|
||||
require('vim.compat')
|
||||
require('coxpcall')
|
||||
local luv = require('luv')
|
||||
local lfs = require('lfs')
|
||||
|
||||
Reference in New Issue
Block a user