mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #10414 from blueyed/luacheck
Improve luacheck integration, fix more issues.
This commit is contained in:
commit
5835398152
19
.luacheckrc
Normal file
19
.luacheckrc
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- vim: ft=lua tw=80
|
||||||
|
|
||||||
|
-- Ignore W211 (unused variable) with preload files.
|
||||||
|
files["**/preload.lua"] = {ignore = { "211" }}
|
||||||
|
|
||||||
|
-- Don't report unused self arguments of methods.
|
||||||
|
self = false
|
||||||
|
|
||||||
|
-- Rerun tests only if their modification time changed.
|
||||||
|
cache = true
|
||||||
|
|
||||||
|
ignore = {
|
||||||
|
"631", -- max_line_length
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Global objects defined by the C code
|
||||||
|
read_globals = {
|
||||||
|
"vim",
|
||||||
|
}
|
@ -666,37 +666,12 @@ if(BUSTED_LUA_PRG)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LUACHECK_PRG)
|
if(LUACHECK_PRG)
|
||||||
add_custom_target(testlint
|
add_custom_target(lualint
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/
|
||||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
|
else()
|
||||||
-DIGNORE_PATTERN="*/preload.lua"
|
add_custom_target(lualint false
|
||||||
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake)
|
COMMENT "lualint: LUACHECK_PRG not defined")
|
||||||
|
|
||||||
add_custom_target(
|
|
||||||
lintbuiltinlua
|
|
||||||
COMMAND
|
|
||||||
${CMAKE_COMMAND}
|
|
||||||
-DLUACHECK_PRG=${LUACHECK_PRG}
|
|
||||||
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/nvim/lua
|
|
||||||
-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
|
|
||||||
-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 lintruntimelua
|
|
||||||
DEPENDS lintbuiltinlua
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_NAME "Neovim")
|
set(CPACK_PACKAGE_NAME "Neovim")
|
||||||
|
7
Makefile
7
Makefile
@ -135,9 +135,6 @@ functionaltest: | nvim
|
|||||||
functionaltest-lua: | nvim
|
functionaltest-lua: | nvim
|
||||||
+$(BUILD_CMD) -C build functionaltest-lua
|
+$(BUILD_CMD) -C build functionaltest-lua
|
||||||
|
|
||||||
testlint: | build/.ran-cmake deps
|
|
||||||
$(BUILD_CMD) -C build testlint
|
|
||||||
|
|
||||||
lualint: | build/.ran-cmake deps
|
lualint: | build/.ran-cmake deps
|
||||||
$(BUILD_CMD) -C build lualint
|
$(BUILD_CMD) -C build lualint
|
||||||
|
|
||||||
@ -182,6 +179,6 @@ appimage:
|
|||||||
appimage-%:
|
appimage-%:
|
||||||
bash scripts/genappimage.sh $*
|
bash scripts/genappimage.sh $*
|
||||||
|
|
||||||
lint: check-single-includes clint testlint lualint
|
lint: check-single-includes clint lualint
|
||||||
|
|
||||||
.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
.PHONY: test lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
||||||
|
@ -14,12 +14,6 @@ run_test 'make clint-full' clint
|
|||||||
|
|
||||||
exit_suite --continue
|
exit_suite --continue
|
||||||
|
|
||||||
enter_suite 'testlint'
|
|
||||||
|
|
||||||
run_test 'make testlint' testlint
|
|
||||||
|
|
||||||
exit_suite --continue
|
|
||||||
|
|
||||||
enter_suite 'lualint'
|
enter_suite 'lualint'
|
||||||
|
|
||||||
run_test 'make lualint' lualint
|
run_test 'make lualint' lualint
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
set(LUACHECK_ARGS -q "${LUAFILES_DIR}")
|
|
||||||
if(DEFINED IGNORE_PATTERN)
|
|
||||||
list(APPEND LUACHECK_ARGS --exclude-files "${LUAFILES_DIR}/${IGNORE_PATTERN}")
|
|
||||||
endif()
|
|
||||||
if(DEFINED CHECK_PATTERN)
|
|
||||||
list(APPEND LUACHECK_ARGS --include-files "${LUAFILES_DIR}/${CHECK_PATTERN}")
|
|
||||||
endif()
|
|
||||||
if(DEFINED READ_GLOBALS)
|
|
||||||
list(APPEND LUACHECK_ARGS --read-globals "${READ_GLOBALS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${LUACHECK_PRG}" ${LUACHECK_ARGS}
|
|
||||||
WORKING_DIRECTORY "${LUAFILES_DIR}"
|
|
||||||
ERROR_VARIABLE err
|
|
||||||
RESULT_VARIABLE res
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT res EQUAL 0)
|
|
||||||
message(STATUS "Output to stderr:\n${err}")
|
|
||||||
message(FATAL_ERROR "Linting tests failed with error: ${res}")
|
|
||||||
endif()
|
|
@ -1,4 +1,4 @@
|
|||||||
lpeg = require('lpeg')
|
local lpeg = require('lpeg')
|
||||||
|
|
||||||
-- lpeg grammar for building api metadata from a set of header files. It
|
-- lpeg grammar for building api metadata from a set of header files. It
|
||||||
-- ignores comments and preprocessor commands and parses a very small subset
|
-- ignores comments and preprocessor commands and parses a very small subset
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
-- we need at least 4 arguments since the last two are output files
|
-- we need at least 4 arguments since the last two are output files
|
||||||
if arg[1] == '--help' then
|
if arg[1] == '--help' then
|
||||||
@ -11,27 +11,27 @@ if arg[1] == '--help' then
|
|||||||
print(' rest: C files where API functions are defined')
|
print(' rest: C files where API functions are defined')
|
||||||
end
|
end
|
||||||
assert(#arg >= 4)
|
assert(#arg >= 4)
|
||||||
functions = {}
|
local functions = {}
|
||||||
|
|
||||||
local nvimdir = arg[1]
|
local nvimdir = arg[1]
|
||||||
package.path = nvimdir .. '/?.lua;' .. package.path
|
package.path = nvimdir .. '/?.lua;' .. package.path
|
||||||
|
|
||||||
-- names of all headers relative to the source root (for inclusion in the
|
-- names of all headers relative to the source root (for inclusion in the
|
||||||
-- generated file)
|
-- generated file)
|
||||||
headers = {}
|
local headers = {}
|
||||||
|
|
||||||
-- output h file with generated dispatch functions
|
-- output h file with generated dispatch functions
|
||||||
dispatch_outputf = arg[2]
|
local dispatch_outputf = arg[2]
|
||||||
-- output h file with packed metadata
|
-- output h file with packed metadata
|
||||||
funcs_metadata_outputf = arg[3]
|
local funcs_metadata_outputf = arg[3]
|
||||||
-- output metadata mpack file, for use by other build scripts
|
-- output metadata mpack file, for use by other build scripts
|
||||||
mpack_outputf = arg[4]
|
local mpack_outputf = arg[4]
|
||||||
lua_c_bindings_outputf = arg[5]
|
local lua_c_bindings_outputf = arg[5]
|
||||||
|
|
||||||
-- set of function names, used to detect duplicates
|
-- set of function names, used to detect duplicates
|
||||||
function_names = {}
|
local function_names = {}
|
||||||
|
|
||||||
c_grammar = require('generators.c_grammar')
|
local c_grammar = require('generators.c_grammar')
|
||||||
|
|
||||||
-- read each input file, parse and append to the api metadata
|
-- read each input file, parse and append to the api metadata
|
||||||
for i = 6, #arg do
|
for i = 6, #arg do
|
||||||
@ -45,10 +45,10 @@ for i = 6, #arg do
|
|||||||
local input = io.open(full_path, 'rb')
|
local input = io.open(full_path, 'rb')
|
||||||
|
|
||||||
local tmp = c_grammar.grammar:match(input:read('*all'))
|
local tmp = c_grammar.grammar:match(input:read('*all'))
|
||||||
for i = 1, #tmp do
|
for j = 1, #tmp do
|
||||||
local fn = tmp[i]
|
local fn = tmp[j]
|
||||||
if not fn.noexport then
|
if not fn.noexport then
|
||||||
functions[#functions + 1] = tmp[i]
|
functions[#functions + 1] = tmp[j]
|
||||||
function_names[fn.name] = true
|
function_names[fn.name] = true
|
||||||
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
||||||
-- this function should receive the channel id
|
-- this function should receive the channel id
|
||||||
@ -83,7 +83,7 @@ end
|
|||||||
-- Export functions under older deprecated names.
|
-- Export functions under older deprecated names.
|
||||||
-- These will be removed eventually.
|
-- These will be removed eventually.
|
||||||
local deprecated_aliases = require("api.dispatch_deprecated")
|
local deprecated_aliases = require("api.dispatch_deprecated")
|
||||||
for i,f in ipairs(shallowcopy(functions)) do
|
for _,f in ipairs(shallowcopy(functions)) do
|
||||||
local ismethod = false
|
local ismethod = false
|
||||||
if startswith(f.name, "nvim_") then
|
if startswith(f.name, "nvim_") then
|
||||||
if startswith(f.name, "nvim__") then
|
if startswith(f.name, "nvim__") then
|
||||||
@ -135,9 +135,9 @@ for i,f in ipairs(shallowcopy(functions)) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- don't expose internal attributes like "impl_name" in public metadata
|
-- don't expose internal attributes like "impl_name" in public metadata
|
||||||
exported_attributes = {'name', 'return_type', 'method',
|
local exported_attributes = {'name', 'return_type', 'method',
|
||||||
'since', 'deprecated_since'}
|
'since', 'deprecated_since'}
|
||||||
exported_functions = {}
|
local exported_functions = {}
|
||||||
for _,f in ipairs(functions) do
|
for _,f in ipairs(functions) do
|
||||||
if not startswith(f.name, "nvim__") then
|
if not startswith(f.name, "nvim__") then
|
||||||
local f_exported = {}
|
local f_exported = {}
|
||||||
@ -158,14 +158,14 @@ end
|
|||||||
|
|
||||||
-- serialize the API metadata using msgpack and embed into the resulting
|
-- serialize the API metadata using msgpack and embed into the resulting
|
||||||
-- binary for easy querying by clients
|
-- binary for easy querying by clients
|
||||||
funcs_metadata_output = io.open(funcs_metadata_outputf, 'wb')
|
local funcs_metadata_output = io.open(funcs_metadata_outputf, 'wb')
|
||||||
packed = mpack.pack(exported_functions)
|
local packed = mpack.pack(exported_functions)
|
||||||
dump_bin_array = require("generators.dump_bin_array")
|
local dump_bin_array = require("generators.dump_bin_array")
|
||||||
dump_bin_array(funcs_metadata_output, 'funcs_metadata', packed)
|
dump_bin_array(funcs_metadata_output, 'funcs_metadata', packed)
|
||||||
funcs_metadata_output:close()
|
funcs_metadata_output:close()
|
||||||
|
|
||||||
-- start building the dispatch wrapper output
|
-- start building the dispatch wrapper output
|
||||||
output = io.open(dispatch_outputf, 'wb')
|
local output = io.open(dispatch_outputf, 'wb')
|
||||||
|
|
||||||
local function real_type(type)
|
local function real_type(type)
|
||||||
local rv = type
|
local rv = type
|
||||||
@ -209,20 +209,22 @@ for i = 1, #functions do
|
|||||||
end
|
end
|
||||||
output:write('\n')
|
output:write('\n')
|
||||||
output:write('\n if (args.size != '..#fn.parameters..') {')
|
output:write('\n if (args.size != '..#fn.parameters..') {')
|
||||||
output:write('\n api_set_error(error, kErrorTypeException, "Wrong number of arguments: expecting '..#fn.parameters..' but got %zu", args.size);')
|
output:write('\n api_set_error(error, kErrorTypeException, \
|
||||||
|
"Wrong number of arguments: expecting '..#fn.parameters..' but got %zu", args.size);')
|
||||||
output:write('\n goto cleanup;')
|
output:write('\n goto cleanup;')
|
||||||
output:write('\n }\n')
|
output:write('\n }\n')
|
||||||
|
|
||||||
-- Validation/conversion for each argument
|
-- Validation/conversion for each argument
|
||||||
for j = 1, #fn.parameters do
|
for j = 1, #fn.parameters do
|
||||||
local converted, convert_arg, param, arg
|
local converted, param
|
||||||
param = fn.parameters[j]
|
param = fn.parameters[j]
|
||||||
converted = 'arg_'..j
|
converted = 'arg_'..j
|
||||||
local rt = real_type(param[1])
|
local rt = real_type(param[1])
|
||||||
if rt ~= 'Object' then
|
if rt ~= 'Object' then
|
||||||
if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') then
|
if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') then
|
||||||
-- Buffer, Window, and Tabpage have a specific type, but are stored in integer
|
-- Buffer, Window, and Tabpage have a specific type, but are stored in integer
|
||||||
output:write('\n if (args.items['..(j - 1)..'].type == kObjectType'..rt..' && args.items['..(j - 1)..'].data.integer >= 0) {')
|
output:write('\n if (args.items['..
|
||||||
|
(j - 1)..'].type == kObjectType'..rt..' && args.items['..(j - 1)..'].data.integer >= 0) {')
|
||||||
output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
|
output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
|
||||||
else
|
else
|
||||||
output:write('\n if (args.items['..(j - 1)..'].type == kObjectType'..rt..') {')
|
output:write('\n if (args.items['..(j - 1)..'].type == kObjectType'..rt..') {')
|
||||||
@ -230,16 +232,18 @@ for i = 1, #functions do
|
|||||||
end
|
end
|
||||||
if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') or rt:match('^Boolean$') then
|
if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') or rt:match('^Boolean$') then
|
||||||
-- accept nonnegative integers for Booleans, Buffers, Windows and Tabpages
|
-- accept nonnegative integers for Booleans, Buffers, Windows and Tabpages
|
||||||
output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeInteger && args.items['..(j - 1)..'].data.integer >= 0) {')
|
output:write('\n } else if (args.items['..
|
||||||
|
(j - 1)..'].type == kObjectTypeInteger && args.items['..(j - 1)..'].data.integer >= 0) {')
|
||||||
output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
|
output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
|
||||||
end
|
end
|
||||||
-- accept empty lua tables as empty dictionarys
|
-- accept empty lua tables as empty dictionarys
|
||||||
if rt:match('^Dictionary') then
|
if rt:match('^Dictionary') then
|
||||||
output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeArray && args.items['..(j - 1)..'].data.array.size == 0) {')
|
output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeArray && args.items['..(j - 1)..'].data.array.size == 0) {') --luacheck: ignore 631
|
||||||
output:write('\n '..converted..' = (Dictionary)ARRAY_DICT_INIT;')
|
output:write('\n '..converted..' = (Dictionary)ARRAY_DICT_INIT;')
|
||||||
end
|
end
|
||||||
output:write('\n } else {')
|
output:write('\n } else {')
|
||||||
output:write('\n api_set_error(error, kErrorTypeException, "Wrong type for argument '..j..', expecting '..param[1]..'");')
|
output:write('\n api_set_error(error, kErrorTypeException, \
|
||||||
|
"Wrong type for argument '..j..', expecting '..param[1]..'");')
|
||||||
output:write('\n goto cleanup;')
|
output:write('\n goto cleanup;')
|
||||||
output:write('\n }\n')
|
output:write('\n }\n')
|
||||||
else
|
else
|
||||||
@ -316,19 +320,19 @@ end
|
|||||||
output:write('\n}\n\n')
|
output:write('\n}\n\n')
|
||||||
output:close()
|
output:close()
|
||||||
|
|
||||||
mpack_output = io.open(mpack_outputf, 'wb')
|
local mpack_output = io.open(mpack_outputf, 'wb')
|
||||||
mpack_output:write(mpack.pack(functions))
|
mpack_output:write(mpack.pack(functions))
|
||||||
mpack_output:close()
|
mpack_output:close()
|
||||||
|
|
||||||
local function include_headers(output, headers)
|
local function include_headers(output_handle, headers_to_include)
|
||||||
for i = 1, #headers do
|
for i = 1, #headers_to_include do
|
||||||
if headers[i]:sub(-12) ~= '.generated.h' then
|
if headers_to_include[i]:sub(-12) ~= '.generated.h' then
|
||||||
output:write('\n#include "nvim/'..headers[i]..'"')
|
output_handle:write('\n#include "nvim/'..headers_to_include[i]..'"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function write_shifted_output(output, str)
|
local function write_shifted_output(_, str)
|
||||||
str = str:gsub('\n ', '\n')
|
str = str:gsub('\n ', '\n')
|
||||||
str = str:gsub('^ ', '')
|
str = str:gsub('^ ', '')
|
||||||
str = str:gsub(' +$', '')
|
str = str:gsub(' +$', '')
|
||||||
@ -354,10 +358,10 @@ output:write([[
|
|||||||
include_headers(output, headers)
|
include_headers(output, headers)
|
||||||
output:write('\n')
|
output:write('\n')
|
||||||
|
|
||||||
lua_c_functions = {}
|
local lua_c_functions = {}
|
||||||
|
|
||||||
local function process_function(fn)
|
local function process_function(fn)
|
||||||
lua_c_function_name = ('nlua_msgpack_%s'):format(fn.name)
|
local lua_c_function_name = ('nlua_msgpack_%s'):format(fn.name)
|
||||||
write_shifted_output(output, string.format([[
|
write_shifted_output(output, string.format([[
|
||||||
|
|
||||||
static int %s(lua_State *lstate)
|
static int %s(lua_State *lstate)
|
||||||
@ -384,11 +388,11 @@ local function process_function(fn)
|
|||||||
local cparams = ''
|
local cparams = ''
|
||||||
local free_code = {}
|
local free_code = {}
|
||||||
for j = #fn.parameters,1,-1 do
|
for j = #fn.parameters,1,-1 do
|
||||||
param = fn.parameters[j]
|
local param = fn.parameters[j]
|
||||||
cparam = string.format('arg%u', j)
|
local cparam = string.format('arg%u', j)
|
||||||
param_type = real_type(param[1])
|
local param_type = real_type(param[1])
|
||||||
lc_param_type = real_type(param[1]):lower()
|
local lc_param_type = real_type(param[1]):lower()
|
||||||
extra = ((param_type == "Object" or param_type == "Dictionary") and "false, ") or ""
|
local extra = ((param_type == "Object" or param_type == "Dictionary") and "false, ") or ""
|
||||||
if param[1] == "DictionaryOf(LuaRef)" then
|
if param[1] == "DictionaryOf(LuaRef)" then
|
||||||
extra = "true, "
|
extra = "true, "
|
||||||
end
|
end
|
||||||
@ -433,6 +437,7 @@ local function process_function(fn)
|
|||||||
return lua_error(lstate);
|
return lua_error(lstate);
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
|
local return_type
|
||||||
if fn.return_type ~= 'void' then
|
if fn.return_type ~= 'void' then
|
||||||
if fn.return_type:match('^ArrayOf') then
|
if fn.return_type:match('^ArrayOf') then
|
||||||
return_type = 'Array'
|
return_type = 'Array'
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
local nvimdir = arg[1]
|
local nvimdir = arg[1]
|
||||||
package.path = nvimdir .. '/?.lua;' .. package.path
|
package.path = nvimdir .. '/?.lua;' .. package.path
|
||||||
|
|
||||||
assert(#arg == 7)
|
assert(#arg == 7)
|
||||||
input = io.open(arg[2], 'rb')
|
local input = io.open(arg[2], 'rb')
|
||||||
proto_output = io.open(arg[3], 'wb')
|
local proto_output = io.open(arg[3], 'wb')
|
||||||
call_output = io.open(arg[4], 'wb')
|
local call_output = io.open(arg[4], 'wb')
|
||||||
remote_output = io.open(arg[5], 'wb')
|
local remote_output = io.open(arg[5], 'wb')
|
||||||
bridge_output = io.open(arg[6], 'wb')
|
local bridge_output = io.open(arg[6], 'wb')
|
||||||
metadata_output = io.open(arg[7], 'wb')
|
local metadata_output = io.open(arg[7], 'wb')
|
||||||
|
|
||||||
c_grammar = require('generators.c_grammar')
|
local c_grammar = require('generators.c_grammar')
|
||||||
local events = c_grammar.grammar:match(input:read('*all'))
|
local events = c_grammar.grammar:match(input:read('*all'))
|
||||||
|
|
||||||
function write_signature(output, ev, prefix, notype)
|
local function write_signature(output, ev, prefix, notype)
|
||||||
output:write('('..prefix)
|
output:write('('..prefix)
|
||||||
if prefix == "" and #ev.parameters == 0 then
|
if prefix == "" and #ev.parameters == 0 then
|
||||||
output:write('void')
|
output:write('void')
|
||||||
@ -32,7 +32,7 @@ function write_signature(output, ev, prefix, notype)
|
|||||||
output:write(')')
|
output:write(')')
|
||||||
end
|
end
|
||||||
|
|
||||||
function write_arglist(output, ev, need_copy)
|
local function write_arglist(output, ev, need_copy)
|
||||||
output:write(' Array args = ARRAY_DICT_INIT;\n')
|
output:write(' Array args = ARRAY_DICT_INIT;\n')
|
||||||
for j = 1, #ev.parameters do
|
for j = 1, #ev.parameters do
|
||||||
local param = ev.parameters[j]
|
local param = ev.parameters[j]
|
||||||
@ -51,7 +51,7 @@ function write_arglist(output, ev, need_copy)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #events do
|
for i = 1, #events do
|
||||||
ev = events[i]
|
local ev = events[i]
|
||||||
assert(ev.return_type == 'void')
|
assert(ev.return_type == 'void')
|
||||||
|
|
||||||
if ev.since == nil and not ev.noexport then
|
if ev.since == nil and not ev.noexport then
|
||||||
@ -75,11 +75,11 @@ for i = 1, #events do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not ev.bridge_impl and not ev.noexport then
|
if not ev.bridge_impl and not ev.noexport then
|
||||||
send, argv, recv, recv_argv, recv_cleanup = '', '', '', '', ''
|
local send, argv, recv, recv_argv, recv_cleanup = '', '', '', '', ''
|
||||||
argc = 1
|
local argc = 1
|
||||||
for j = 1, #ev.parameters do
|
for j = 1, #ev.parameters do
|
||||||
local param = ev.parameters[j]
|
local param = ev.parameters[j]
|
||||||
copy = 'copy_'..param[2]
|
local copy = 'copy_'..param[2]
|
||||||
if param[1] == 'String' then
|
if param[1] == 'String' then
|
||||||
send = send..' String copy_'..param[2]..' = copy_string('..param[2]..');\n'
|
send = send..' String copy_'..param[2]..' = copy_string('..param[2]..');\n'
|
||||||
argv = argv..', '..copy..'.data, INT2PTR('..copy..'.size)'
|
argv = argv..', '..copy..'.data, INT2PTR('..copy..'.size)'
|
||||||
@ -160,7 +160,6 @@ for i = 1, #events do
|
|||||||
call_output:write(";\n")
|
call_output:write(";\n")
|
||||||
call_output:write("}\n\n")
|
call_output:write("}\n\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
proto_output:close()
|
proto_output:close()
|
||||||
@ -169,9 +168,9 @@ remote_output:close()
|
|||||||
bridge_output:close()
|
bridge_output:close()
|
||||||
|
|
||||||
-- don't expose internal attributes like "impl_name" in public metadata
|
-- don't expose internal attributes like "impl_name" in public metadata
|
||||||
exported_attributes = {'name', 'parameters',
|
local exported_attributes = {'name', 'parameters',
|
||||||
'since', 'deprecated_since'}
|
'since', 'deprecated_since'}
|
||||||
exported_events = {}
|
local exported_events = {}
|
||||||
for _,ev in ipairs(events) do
|
for _,ev in ipairs(events) do
|
||||||
local ev_exported = {}
|
local ev_exported = {}
|
||||||
for _,attr in ipairs(exported_attributes) do
|
for _,attr in ipairs(exported_attributes) do
|
||||||
@ -187,7 +186,7 @@ for _,ev in ipairs(events) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
packed = mpack.pack(exported_events)
|
local packed = mpack.pack(exported_events)
|
||||||
dump_bin_array = require("generators.dump_bin_array")
|
local dump_bin_array = require("generators.dump_bin_array")
|
||||||
dump_bin_array(metadata_output, 'ui_events_metadata', packed)
|
dump_bin_array(metadata_output, 'ui_events_metadata', packed)
|
||||||
metadata_output:close()
|
metadata_output:close()
|
||||||
|
@ -13,16 +13,17 @@ local source_file = arg[1]
|
|||||||
local target_file = arg[2]
|
local target_file = arg[2]
|
||||||
local varname = arg[3]
|
local varname = arg[3]
|
||||||
|
|
||||||
source = io.open(source_file, 'r')
|
local source = io.open(source_file, 'r')
|
||||||
target = io.open(target_file, 'w')
|
local target = io.open(target_file, 'w')
|
||||||
|
|
||||||
target:write('#include <stdint.h>\n\n')
|
target:write('#include <stdint.h>\n\n')
|
||||||
target:write(('static const uint8_t %s[] = {\n'):format(varname))
|
target:write(('static const uint8_t %s[] = {\n'):format(varname))
|
||||||
|
|
||||||
num_bytes = 0
|
local num_bytes = 0
|
||||||
MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
|
local MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
|
||||||
target:write(' ')
|
target:write(' ')
|
||||||
|
|
||||||
|
local increase_num_bytes
|
||||||
increase_num_bytes = function()
|
increase_num_bytes = function()
|
||||||
num_bytes = num_bytes + 1
|
num_bytes = num_bytes + 1
|
||||||
if num_bytes == MAX_NUM_BYTES then
|
if num_bytes == MAX_NUM_BYTES then
|
||||||
@ -33,7 +34,7 @@ end
|
|||||||
|
|
||||||
for line in source:lines() do
|
for line in source:lines() do
|
||||||
for i = 1,string.len(line) do
|
for i = 1,string.len(line) do
|
||||||
byte = string.byte(line, i)
|
local byte = string.byte(line, i)
|
||||||
assert(byte ~= 0)
|
assert(byte ~= 0)
|
||||||
target:write(string.format(' %3u,', byte))
|
target:write(string.format(' %3u,', byte))
|
||||||
increase_num_bytes()
|
increase_num_bytes()
|
||||||
|
@ -10,7 +10,7 @@ local lpeg = require('lpeg')
|
|||||||
|
|
||||||
local fold = function (func, ...)
|
local fold = function (func, ...)
|
||||||
local result = nil
|
local result = nil
|
||||||
for i, v in ipairs({...}) do
|
for _, v in ipairs({...}) do
|
||||||
if result == nil then
|
if result == nil then
|
||||||
result = v
|
result = v
|
||||||
else
|
else
|
||||||
@ -107,7 +107,7 @@ local typ_part = concat(
|
|||||||
)),
|
)),
|
||||||
spaces
|
spaces
|
||||||
)
|
)
|
||||||
local typ = one_or_more(typ_part)
|
|
||||||
local typ_id = two_or_more(typ_part)
|
local typ_id = two_or_more(typ_part)
|
||||||
local arg = typ_id -- argument name is swallowed by typ
|
local arg = typ_id -- argument name is swallowed by typ
|
||||||
local pattern = concat(
|
local pattern = concat(
|
||||||
@ -222,7 +222,6 @@ local non_static = header
|
|||||||
local static = header
|
local static = header
|
||||||
|
|
||||||
local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"'
|
local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"'
|
||||||
local curfile
|
|
||||||
|
|
||||||
local init = 1
|
local init = 1
|
||||||
local curfile = nil
|
local curfile = nil
|
||||||
@ -248,11 +247,11 @@ while init ~= nil do
|
|||||||
else
|
else
|
||||||
declline = declline - 1
|
declline = declline - 1
|
||||||
end
|
end
|
||||||
elseif init < declendpos then
|
elseif init < declendpos then -- luacheck: ignore 542
|
||||||
-- Skipping over declaration
|
-- Skipping over declaration
|
||||||
elseif is_needed_file then
|
elseif is_needed_file then
|
||||||
s = init
|
s = init
|
||||||
e = pattern:match(text, init)
|
local e = pattern:match(text, init)
|
||||||
if e ~= nil then
|
if e ~= nil then
|
||||||
local declaration = text:sub(s, e - 1)
|
local declaration = text:sub(s, e - 1)
|
||||||
-- Comments are really handled by preprocessor, so the following is not
|
-- Comments are really handled by preprocessor, so the following is not
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
local nvimsrcdir = arg[1]
|
local nvimsrcdir = arg[1]
|
||||||
local autodir = arg[2]
|
local autodir = arg[2]
|
||||||
@ -23,8 +23,8 @@ local funcsfname = autodir .. '/funcs.generated.h'
|
|||||||
local gperfpipe = io.open(funcsfname .. '.gperf', 'wb')
|
local gperfpipe = io.open(funcsfname .. '.gperf', 'wb')
|
||||||
|
|
||||||
local funcs = require('eval').funcs
|
local funcs = require('eval').funcs
|
||||||
local metadata = mpack.unpack(io.open(arg[3], 'rb'):read("*all"))
|
local metadata = mpack.unpack(io.open(metadata_file, 'rb'):read("*all"))
|
||||||
for i,fun in ipairs(metadata) do
|
for _,fun in ipairs(metadata) do
|
||||||
if not fun.remote_only then
|
if not fun.remote_only then
|
||||||
funcs[fun.name] = {
|
funcs[fun.name] = {
|
||||||
args=#fun.parameters,
|
args=#fun.parameters,
|
||||||
@ -53,14 +53,14 @@ VimLFuncDef;
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
for name, def in pairs(funcs) do
|
for name, def in pairs(funcs) do
|
||||||
args = def.args or 0
|
local args = def.args or 0
|
||||||
if type(args) == 'number' then
|
if type(args) == 'number' then
|
||||||
args = {args, args}
|
args = {args, args}
|
||||||
elseif #args == 1 then
|
elseif #args == 1 then
|
||||||
args[2] = 'MAX_FUNC_ARGS'
|
args[2] = 'MAX_FUNC_ARGS'
|
||||||
end
|
end
|
||||||
func = def.func or ('f_' .. name)
|
local func = def.func or ('f_' .. name)
|
||||||
data = def.data or "NULL"
|
local data = def.data or "NULL"
|
||||||
gperfpipe:write(('%s, %s, %s, &%s, (FunPtr)%s\n')
|
gperfpipe:write(('%s, %s, %s, &%s, (FunPtr)%s\n')
|
||||||
:format(name, args[1], args[2], func, data))
|
:format(name, args[1], args[2], func, data))
|
||||||
end
|
end
|
||||||
|
@ -13,8 +13,8 @@ local auevents = require('auevents')
|
|||||||
local events = auevents.events
|
local events = auevents.events
|
||||||
local aliases = auevents.aliases
|
local aliases = auevents.aliases
|
||||||
|
|
||||||
enum_tgt = io.open(fileio_enum_file, 'w')
|
local enum_tgt = io.open(fileio_enum_file, 'w')
|
||||||
names_tgt = io.open(names_file, 'w')
|
local names_tgt = io.open(names_file, 'w')
|
||||||
|
|
||||||
enum_tgt:write('typedef enum auto_event {')
|
enum_tgt:write('typedef enum auto_event {')
|
||||||
names_tgt:write([[
|
names_tgt:write([[
|
||||||
@ -42,8 +42,8 @@ enum_tgt:write('\n} event_T;\n')
|
|||||||
names_tgt:write('\n};\n')
|
names_tgt:write('\n};\n')
|
||||||
|
|
||||||
names_tgt:write('\nstatic AutoPat *first_autopat[NUM_EVENTS] = {\n ')
|
names_tgt:write('\nstatic AutoPat *first_autopat[NUM_EVENTS] = {\n ')
|
||||||
line_len = 1
|
local line_len = 1
|
||||||
for i = 1,((#events) - 1) do
|
for _ = 1,((#events) - 1) do
|
||||||
line_len = line_len + #(' NULL,')
|
line_len = line_len + #(' NULL,')
|
||||||
if line_len > 80 then
|
if line_len > 80 then
|
||||||
names_tgt:write('\n ')
|
names_tgt:write('\n ')
|
||||||
|
@ -23,10 +23,7 @@ local enumfile = io.open(enumfname, 'w')
|
|||||||
local defsfile = io.open(defsfname, 'w')
|
local defsfile = io.open(defsfname, 'w')
|
||||||
|
|
||||||
local defs = require('ex_cmds')
|
local defs = require('ex_cmds')
|
||||||
local lastchar = nil
|
|
||||||
|
|
||||||
local i
|
|
||||||
local cmd
|
|
||||||
local first = true
|
local first = true
|
||||||
|
|
||||||
local byte_a = string.byte('a')
|
local byte_a = string.byte('a')
|
||||||
@ -58,7 +55,7 @@ defsfile:write(string.format([[
|
|||||||
static CommandDefinition cmdnames[%u] = {
|
static CommandDefinition cmdnames[%u] = {
|
||||||
]], #defs))
|
]], #defs))
|
||||||
local cmds, cmdidxs1, cmdidxs2 = {}, {}, {}
|
local cmds, cmdidxs1, cmdidxs2 = {}, {}, {}
|
||||||
for i, cmd in ipairs(defs) do
|
for _, cmd in ipairs(defs) do
|
||||||
local enumname = cmd.enum or ('CMD_' .. cmd.command)
|
local enumname = cmd.enum or ('CMD_' .. cmd.command)
|
||||||
local byte_cmd = cmd.command:sub(1, 1):byte()
|
local byte_cmd = cmd.command:sub(1, 1):byte()
|
||||||
if byte_a <= byte_cmd and byte_cmd <= byte_z then
|
if byte_a <= byte_cmd and byte_cmd <= byte_z then
|
||||||
|
@ -20,7 +20,7 @@ end
|
|||||||
|
|
||||||
local options = require('options')
|
local options = require('options')
|
||||||
|
|
||||||
cstr = options.cstr
|
local cstr = options.cstr
|
||||||
|
|
||||||
local type_flags={
|
local type_flags={
|
||||||
bool='P_BOOL',
|
bool='P_BOOL',
|
||||||
@ -108,12 +108,12 @@ get_cond = function(c, base_string)
|
|||||||
return cond_string
|
return cond_string
|
||||||
end
|
end
|
||||||
|
|
||||||
value_dumpers = {
|
local value_dumpers = {
|
||||||
['function']=function(v) return v() end,
|
['function']=function(v) return v() end,
|
||||||
string=cstr,
|
string=cstr,
|
||||||
boolean=function(v) return v and 'true' or 'false' end,
|
boolean=function(v) return v and 'true' or 'false' end,
|
||||||
number=function(v) return ('%iL'):format(v) end,
|
number=function(v) return ('%iL'):format(v) end,
|
||||||
['nil']=function(v) return '0L' end,
|
['nil']=function(_) return '0L' end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local get_value = function(v)
|
local get_value = function(v)
|
||||||
|
@ -38,7 +38,7 @@ local split_on_semicolons = function(s)
|
|||||||
local ret = {}
|
local ret = {}
|
||||||
local idx = 1
|
local idx = 1
|
||||||
while idx <= #s + 1 do
|
while idx <= #s + 1 do
|
||||||
item = s:match('^[^;]*', idx)
|
local item = s:match('^[^;]*', idx)
|
||||||
idx = idx + #item + 1
|
idx = idx + #item + 1
|
||||||
if idx <= #s + 1 then
|
if idx <= #s + 1 then
|
||||||
assert(s:sub(idx - 1, idx - 1) == ';')
|
assert(s:sub(idx - 1, idx - 1) == ';')
|
||||||
@ -208,7 +208,7 @@ local build_width_table = function(ut_fp, dataprops, widthprops, widths,
|
|||||||
-- But use all chars from a range.
|
-- But use all chars from a range.
|
||||||
local dp = dataprops[dataidx]
|
local dp = dataprops[dataidx]
|
||||||
if (n_last > n) or (not (({Mn=true, Mc=true, Me=true})[dp[3]])) then
|
if (n_last > n) or (not (({Mn=true, Mc=true, Me=true})[dp[3]])) then
|
||||||
if start >= 0 and end_ + 1 == n then
|
if start >= 0 and end_ + 1 == n then -- luacheck: ignore 542
|
||||||
-- Continue with the same range.
|
-- Continue with the same range.
|
||||||
else
|
else
|
||||||
if start >= 0 then
|
if start >= 0 then
|
||||||
@ -235,6 +235,8 @@ local build_emoji_table = function(ut_fp, emojiprops, doublewidth, ambiwidth)
|
|||||||
for _, p in ipairs(emojiprops) do
|
for _, p in ipairs(emojiprops) do
|
||||||
if p[2]:match('Emoji%s+#') then
|
if p[2]:match('Emoji%s+#') then
|
||||||
local rng_start, rng_end = p[1]:find('%.%.')
|
local rng_start, rng_end = p[1]:find('%.%.')
|
||||||
|
local n
|
||||||
|
local n_last
|
||||||
if rng_start then
|
if rng_start then
|
||||||
n = tonumber(p[1]:sub(1, rng_start - 1), 16)
|
n = tonumber(p[1]:sub(1, rng_start - 1), 16)
|
||||||
n_last = tonumber(p[1]:sub(rng_end + 1), 16)
|
n_last = tonumber(p[1]:sub(rng_end + 1), 16)
|
||||||
|
@ -40,7 +40,7 @@ local imacros=function(s)
|
|||||||
return '(intptr_t)' .. s
|
return '(intptr_t)' .. s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local N_=function(s)
|
local N_=function(s) -- luacheck: ignore 211 (currently unused)
|
||||||
return function()
|
return function()
|
||||||
return 'N_(' .. cstr(s) .. ')'
|
return 'N_(' .. cstr(s) .. ')'
|
||||||
end
|
end
|
||||||
@ -189,7 +189,6 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='belloff', abbreviation='bo',
|
full_name='belloff', abbreviation='bo',
|
||||||
deny_duplicates=true,
|
|
||||||
type='string', list='comma', scope={'global'},
|
type='string', list='comma', scope={'global'},
|
||||||
deny_duplicates=true,
|
deny_duplicates=true,
|
||||||
vi_def=true,
|
vi_def=true,
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
-- vim: ft=lua tw=80
|
|
||||||
|
|
||||||
-- Don't report globals from luajit or busted (e.g. jit.os or describe).
|
|
||||||
std = '+luajit +busted'
|
|
||||||
|
|
||||||
-- One can't test these files properly; assume correctness.
|
|
||||||
exclude_files = { '*/preload.lua' }
|
|
||||||
|
|
||||||
-- Don't report unused self arguments of methods.
|
|
||||||
self = false
|
|
||||||
|
|
||||||
-- Rerun tests only if their modification time changed.
|
|
||||||
cache = true
|
|
||||||
|
|
||||||
ignore = {
|
|
||||||
"631", -- max_line_length
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Ignore whitespace issues in converted Vim legacy tests.
|
|
||||||
--files["functional/legacy"] = {ignore = { "611", "612", "613", "621" }}
|
|
@ -208,8 +208,6 @@ Guidelines
|
|||||||
[contained in an `it()` block](https://github.com/neovim/neovim/blob/d21690a66e7eb5ebef18046c7a79ef898966d786/test/functional/ex_cmds/grep_spec.lua#L11).
|
[contained in an `it()` block](https://github.com/neovim/neovim/blob/d21690a66e7eb5ebef18046c7a79ef898966d786/test/functional/ex_cmds/grep_spec.lua#L11).
|
||||||
Provide empty function argument if the `pending()` call is outside of `it()`
|
Provide empty function argument if the `pending()` call is outside of `it()`
|
||||||
([example](https://github.com/neovim/neovim/commit/5c1dc0fbe7388528875aff9d7b5055ad718014de#diff-bf80b24c724b0004e8418102f68b0679R18)).
|
([example](https://github.com/neovim/neovim/commit/5c1dc0fbe7388528875aff9d7b5055ad718014de#diff-bf80b24c724b0004e8418102f68b0679R18)).
|
||||||
- Use `make testlint` for using the shipped luacheck program ([supported by syntastic](https://github.com/scrooloose/syntastic/blob/d6b96c079be137c83009827b543a83aa113cc011/doc/syntastic-checkers.txt#L3546))
|
|
||||||
to lint all tests.
|
|
||||||
- Really long `source([=[...]=])` blocks may break syntax highlighting. Try
|
- Really long `source([=[...]=])` blocks may break syntax highlighting. Try
|
||||||
`:syntax sync fromstart` to fix it.
|
`:syntax sync fromstart` to fix it.
|
||||||
|
|
||||||
@ -235,7 +233,7 @@ by the semantic component they are testing.
|
|||||||
Lint
|
Lint
|
||||||
====
|
====
|
||||||
|
|
||||||
`make lint` (and `make testlint`) runs [luacheck](https://github.com/mpeterv/luacheck)
|
`make lint` (and `make lualint`) runs [luacheck](https://github.com/mpeterv/luacheck)
|
||||||
on the test code.
|
on the test code.
|
||||||
|
|
||||||
If a luacheck warning must be ignored, specify the warning code. Example:
|
If a luacheck warning must be ignored, specify the warning code. Example:
|
||||||
|
Loading…
Reference in New Issue
Block a user