mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
build(lint): check scripts/*.lua
This commit is contained in:
parent
39c886551b
commit
736299bf22
@ -25,3 +25,7 @@ ignore = {
|
|||||||
read_globals = {
|
read_globals = {
|
||||||
"vim",
|
"vim",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exclude_files = {
|
||||||
|
'test/functional/fixtures/lua/syntax_error.lua',
|
||||||
|
}
|
||||||
|
@ -691,7 +691,7 @@ endif()
|
|||||||
|
|
||||||
if(LUACHECK_PRG)
|
if(LUACHECK_PRG)
|
||||||
add_custom_target(lualint
|
add_custom_target(lualint
|
||||||
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/ --exclude-files test/functional/fixtures/lua/syntax_error.lua
|
COMMAND ${LUACHECK_PRG} -q runtime/ scripts/ src/ test/
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
else()
|
else()
|
||||||
add_custom_target(lualint false
|
add_custom_target(lualint false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
if arg[1] == '--help' then
|
if arg[1] == '--help' then
|
||||||
print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim')
|
print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim')
|
||||||
@ -52,7 +52,7 @@ local function is_autocmd_cmd(cmd)
|
|||||||
or cmd == 'doautoall')
|
or cmd == 'doautoall')
|
||||||
end
|
end
|
||||||
|
|
||||||
vimcmd_start = 'syn keyword vimCommand contained '
|
local vimcmd_start = 'syn keyword vimCommand contained '
|
||||||
w(vimcmd_start)
|
w(vimcmd_start)
|
||||||
local prev_cmd = nil
|
local prev_cmd = nil
|
||||||
for _, cmd_desc in ipairs(ex_cmds.cmds) do
|
for _, cmd_desc in ipairs(ex_cmds.cmds) do
|
||||||
@ -123,9 +123,8 @@ end
|
|||||||
w('\n\nsyn case match')
|
w('\n\nsyn case match')
|
||||||
local vimfun_start = 'syn keyword vimFuncName contained '
|
local vimfun_start = 'syn keyword vimFuncName contained '
|
||||||
w('\n\n' .. vimfun_start)
|
w('\n\n' .. vimfun_start)
|
||||||
funcs = mpack.unpack(io.open(funcs_file, 'rb'):read("*all"))
|
local funcs = mpack.unpack(io.open(funcs_file, 'rb'):read("*all"))
|
||||||
local started = 0
|
for name, _ in pairs(funcs) do
|
||||||
for name, def in pairs(funcs) do
|
|
||||||
if name then
|
if name then
|
||||||
if lld.line_length > 850 then
|
if lld.line_length > 850 then
|
||||||
w('\n' .. vimfun_start)
|
w('\n' .. vimfun_start)
|
||||||
|
@ -50,7 +50,7 @@ However I have put in a hack that will insert the "missing" close paren.
|
|||||||
The effect is that you will get the function documented, but not with the parameter list you might expect.
|
The effect is that you will get the function documented, but not with the parameter list you might expect.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function class(BaseClass, ClassInitialiser)
|
local function class(BaseClass, ClassInitialiser)
|
||||||
local newClass = {} -- a new class newClass
|
local newClass = {} -- a new class newClass
|
||||||
if not ClassInitialiser and type(BaseClass) == 'function' then
|
if not ClassInitialiser and type(BaseClass) == 'function' then
|
||||||
ClassInitialiser = BaseClass
|
ClassInitialiser = BaseClass
|
||||||
@ -68,8 +68,7 @@ function class(BaseClass, ClassInitialiser)
|
|||||||
|
|
||||||
-- expose a constructor which can be called by <classname>(<args>)
|
-- expose a constructor which can be called by <classname>(<args>)
|
||||||
local classMetatable = {}
|
local classMetatable = {}
|
||||||
classMetatable.__call =
|
classMetatable.__call = function(class_tbl, ...)
|
||||||
function(class_tbl, ...)
|
|
||||||
local newInstance = {}
|
local newInstance = {}
|
||||||
setmetatable(newInstance,newClass)
|
setmetatable(newInstance,newClass)
|
||||||
--if init then
|
--if init then
|
||||||
@ -85,8 +84,7 @@ function class(BaseClass, ClassInitialiser)
|
|||||||
return newInstance
|
return newInstance
|
||||||
end
|
end
|
||||||
newClass.init = ClassInitialiser
|
newClass.init = ClassInitialiser
|
||||||
newClass.is_a =
|
newClass.is_a = function(this, klass)
|
||||||
function(this, klass)
|
|
||||||
local thisMetatable = getmetatable(this)
|
local thisMetatable = getmetatable(this)
|
||||||
while thisMetatable do
|
while thisMetatable do
|
||||||
if thisMetatable == klass then
|
if thisMetatable == klass then
|
||||||
@ -102,12 +100,13 @@ end
|
|||||||
|
|
||||||
--! \class TCore_Clock
|
--! \class TCore_Clock
|
||||||
--! \brief a clock
|
--! \brief a clock
|
||||||
TCore_Clock = class()
|
local TCore_Clock = class()
|
||||||
|
|
||||||
--! \brief get the current time
|
--! \brief get the current time
|
||||||
function TCore_Clock.GetTimeNow()
|
function TCore_Clock.GetTimeNow()
|
||||||
if os.gettimeofday then
|
local gettimeofday = os.gettimeofday -- luacheck: ignore 143 Accessing an undefined field of a global variable.
|
||||||
return os.gettimeofday()
|
if gettimeofday then
|
||||||
|
return gettimeofday()
|
||||||
else
|
else
|
||||||
return os.time()
|
return os.time()
|
||||||
end
|
end
|
||||||
@ -134,20 +133,15 @@ function TCore_Clock.getTimeStamp(this,T0)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--! \brief io to console
|
|
||||||
--!
|
|
||||||
--! pseudo class (no methods, just to keep documentation tidy)
|
|
||||||
TCore_IO = class()
|
|
||||||
--
|
|
||||||
--! \brief write to stdout
|
--! \brief write to stdout
|
||||||
function TCore_IO_write(Str)
|
local function TCore_IO_write(Str)
|
||||||
if (Str) then
|
if (Str) then
|
||||||
io.write(Str)
|
io.write(Str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--! \brief write to stdout
|
--! \brief write to stdout
|
||||||
function TCore_IO_writeln(Str)
|
local function TCore_IO_writeln(Str)
|
||||||
if (Str) then
|
if (Str) then
|
||||||
io.write(Str)
|
io.write(Str)
|
||||||
end
|
end
|
||||||
@ -156,7 +150,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--! \brief trims a string
|
--! \brief trims a string
|
||||||
function string_trim(Str)
|
local function string_trim(Str)
|
||||||
return Str:match("^%s*(.-)%s*$")
|
return Str:match("^%s*(.-)%s*$")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -165,7 +159,7 @@ end
|
|||||||
--! \param Str
|
--! \param Str
|
||||||
--! \param Pattern
|
--! \param Pattern
|
||||||
--! \returns table of string fragments
|
--! \returns table of string fragments
|
||||||
function string_split(Str, Pattern)
|
local function string_split(Str, Pattern)
|
||||||
local splitStr = {}
|
local splitStr = {}
|
||||||
local fpat = "(.-)" .. Pattern
|
local fpat = "(.-)" .. Pattern
|
||||||
local last_end = 1
|
local last_end = 1
|
||||||
@ -187,7 +181,7 @@ end
|
|||||||
|
|
||||||
--! \class TCore_Commandline
|
--! \class TCore_Commandline
|
||||||
--! \brief reads/parses commandline
|
--! \brief reads/parses commandline
|
||||||
TCore_Commandline = class()
|
local TCore_Commandline = class()
|
||||||
|
|
||||||
--! \brief constructor
|
--! \brief constructor
|
||||||
function TCore_Commandline.init(this)
|
function TCore_Commandline.init(this)
|
||||||
@ -209,28 +203,20 @@ end
|
|||||||
--! \brief file buffer
|
--! \brief file buffer
|
||||||
--!
|
--!
|
||||||
--! an input file buffer
|
--! an input file buffer
|
||||||
TStream_Read = class()
|
local TStream_Read = class()
|
||||||
|
|
||||||
--! \brief get contents of file
|
--! \brief get contents of file
|
||||||
--!
|
--!
|
||||||
--! \param Filename name of file to read (or nil == stdin)
|
--! \param Filename name of file to read (or nil == stdin)
|
||||||
function TStream_Read.getContents(this,Filename)
|
function TStream_Read.getContents(this,Filename)
|
||||||
|
assert(Filename)
|
||||||
-- get lines from file
|
-- get lines from file
|
||||||
local filecontents
|
|
||||||
if Filename then
|
|
||||||
-- syphon lines to our table
|
-- syphon lines to our table
|
||||||
--TCore_Debug_show_var('Filename',Filename)
|
--TCore_Debug_show_var('Filename',Filename)
|
||||||
filecontents={}
|
local filecontents={}
|
||||||
for line in io.lines(Filename) do
|
for line in io.lines(Filename) do
|
||||||
table.insert(filecontents,line)
|
table.insert(filecontents,line)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
-- get stuff from stdin as a long string (with crlfs etc)
|
|
||||||
filecontents=io.read('*a')
|
|
||||||
-- make it a table of lines
|
|
||||||
filecontents = TString_split(filecontents,'[\n]') -- note this only works for unix files.
|
|
||||||
Filename = 'stdin'
|
|
||||||
end
|
|
||||||
|
|
||||||
if filecontents then
|
if filecontents then
|
||||||
this.filecontents = filecontents
|
this.filecontents = filecontents
|
||||||
@ -278,7 +264,7 @@ function TStream_Read.eof(this)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--! \brief output stream
|
--! \brief output stream
|
||||||
TStream_Write = class()
|
local TStream_Write = class()
|
||||||
|
|
||||||
--! \brief constructor
|
--! \brief constructor
|
||||||
function TStream_Write.init(this)
|
function TStream_Write.init(this)
|
||||||
@ -286,17 +272,17 @@ function TStream_Write.init(this)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--! \brief write immediately
|
--! \brief write immediately
|
||||||
function TStream_Write.write(this,Str)
|
function TStream_Write.write(_,Str)
|
||||||
TCore_IO_write(Str)
|
TCore_IO_write(Str)
|
||||||
end
|
end
|
||||||
|
|
||||||
--! \brief write immediately
|
--! \brief write immediately
|
||||||
function TStream_Write.writeln(this,Str)
|
function TStream_Write.writeln(_,Str)
|
||||||
TCore_IO_writeln(Str)
|
TCore_IO_writeln(Str)
|
||||||
end
|
end
|
||||||
|
|
||||||
--! \brief write immediately
|
--! \brief write immediately
|
||||||
function TStream_Write.writelnComment(this,Str)
|
function TStream_Write.writelnComment(_,Str)
|
||||||
TCore_IO_write('// ZZ: ')
|
TCore_IO_write('// ZZ: ')
|
||||||
TCore_IO_writeln(Str)
|
TCore_IO_writeln(Str)
|
||||||
end
|
end
|
||||||
@ -311,14 +297,14 @@ end
|
|||||||
|
|
||||||
--! \brief outout tail lines
|
--! \brief outout tail lines
|
||||||
function TStream_Write.write_tailLines(this)
|
function TStream_Write.write_tailLines(this)
|
||||||
for k,line in ipairs(this.tailLine) do
|
for _,line in ipairs(this.tailLine) do
|
||||||
TCore_IO_writeln(line)
|
TCore_IO_writeln(line)
|
||||||
end
|
end
|
||||||
TCore_IO_write('// Lua2DoX new eof')
|
TCore_IO_write('// Lua2DoX new eof')
|
||||||
end
|
end
|
||||||
|
|
||||||
--! \brief input filter
|
--! \brief input filter
|
||||||
TLua2DoX_filter = class()
|
local TLua2DoX_filter = class()
|
||||||
|
|
||||||
--! \brief allow us to do errormessages
|
--! \brief allow us to do errormessages
|
||||||
function TLua2DoX_filter.warning(this,Line,LineNo,Legend)
|
function TLua2DoX_filter.warning(this,Line,LineNo,Legend)
|
||||||
@ -371,12 +357,12 @@ local function checkComment4fn(Fn_magic,MagicLines)
|
|||||||
|
|
||||||
local macro,tail
|
local macro,tail
|
||||||
|
|
||||||
for k,line in ipairs(magicLines) do
|
for _, line in ipairs(magicLines) do
|
||||||
macro,tail = getMagicDirective(line)
|
macro,tail = getMagicDirective(line)
|
||||||
if macro == 'fn' then
|
if macro == 'fn' then
|
||||||
fn_magic = tail
|
fn_magic = tail
|
||||||
-- TCore_IO_writeln('// found fn "' .. fn_magic .. '"')
|
-- TCore_IO_writeln('// found fn "' .. fn_magic .. '"')
|
||||||
else
|
--else
|
||||||
--TCore_IO_writeln('// not found fn "' .. line .. '"')
|
--TCore_IO_writeln('// not found fn "' .. line .. '"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -385,8 +371,6 @@ local function checkComment4fn(Fn_magic,MagicLines)
|
|||||||
end
|
end
|
||||||
--! \brief run the filter
|
--! \brief run the filter
|
||||||
function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
||||||
local err
|
|
||||||
|
|
||||||
local inStream = TStream_Read()
|
local inStream = TStream_Read()
|
||||||
local outStream = TStream_Write()
|
local outStream = TStream_Write()
|
||||||
this.outStream = outStream -- save to this obj
|
this.outStream = outStream -- save to this obj
|
||||||
@ -401,8 +385,9 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
|||||||
outStream:writelnTail('// #######################')
|
outStream:writelnTail('// #######################')
|
||||||
outStream:writelnTail()
|
outStream:writelnTail()
|
||||||
|
|
||||||
local state, offset = '', 0
|
local state = '' -- luacheck: ignore 231 variable is set but never accessed.
|
||||||
while not (err or inStream:eof()) do
|
local offset = 0
|
||||||
|
while not (inStream:eof()) do
|
||||||
line = string_trim(inStream:getLine())
|
line = string_trim(inStream:getLine())
|
||||||
-- TCore_Debug_show_var('inStream',inStream)
|
-- TCore_Debug_show_var('inStream',inStream)
|
||||||
-- TCore_Debug_show_var('line',line )
|
-- TCore_Debug_show_var('line',line )
|
||||||
@ -427,7 +412,7 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
|||||||
line = string.sub(line,5) -- nibble head
|
line = string.sub(line,5) -- nibble head
|
||||||
local comment = ''
|
local comment = ''
|
||||||
local closeSquare,hitend,thisComment
|
local closeSquare,hitend,thisComment
|
||||||
while (not err) and (not hitend) and (not inStream:eof()) do
|
while (not hitend) and (not inStream:eof()) do
|
||||||
closeSquare = string.find(line,']]')
|
closeSquare = string.find(line,']]')
|
||||||
if not closeSquare then -- need to look on another line
|
if not closeSquare then -- need to look on another line
|
||||||
thisComment = line .. '\n'
|
thisComment = line .. '\n'
|
||||||
@ -544,7 +529,7 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--! \brief this application
|
--! \brief this application
|
||||||
TApp = class()
|
local TApp = class()
|
||||||
|
|
||||||
--! \brief constructor
|
--! \brief constructor
|
||||||
function TApp.init(this)
|
function TApp.init(this)
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
|
|
||||||
local nvim = vim.api
|
local nvim = vim.api
|
||||||
|
|
||||||
local function pprint(o)
|
|
||||||
print(nvim.nvim_call_function('string', { o }))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function systemlist(...)
|
local function systemlist(...)
|
||||||
local rv = nvim.nvim_call_function('systemlist', ...)
|
local rv = nvim.nvim_call_function('systemlist', ...)
|
||||||
local err = nvim.nvim_get_vvar('shell_error')
|
local err = nvim.nvim_get_vvar('shell_error')
|
||||||
|
Loading…
Reference in New Issue
Block a user