mirror of
https://github.com/neovim/neovim.git
synced 2025-12-02 23:13:01 +00:00
build: enable lintlua for test/unit/ dir #26396
Problem: Not all Lua code is checked by stylua. Automating code-style is an important mechanism for reducing time spent on accidental (non-essential) complexity. Solution: - Enable lintlua for `test/unit/` directory. - TODO: only `test/functional/` remains unchecked. previous:45fe4d11adprevious:517f0cc634
This commit is contained in:
@@ -3,13 +3,19 @@ local mpack = require('mpack')
|
||||
-- temporary hack to be able to manipulate buffer/window/tabpage
|
||||
local Buffer = {}
|
||||
Buffer.__index = Buffer
|
||||
function Buffer.new(id) return setmetatable({id=id}, Buffer) end
|
||||
function Buffer.new(id)
|
||||
return setmetatable({ id = id }, Buffer)
|
||||
end
|
||||
local Window = {}
|
||||
Window.__index = Window
|
||||
function Window.new(id) return setmetatable({id=id}, Window) end
|
||||
function Window.new(id)
|
||||
return setmetatable({ id = id }, Window)
|
||||
end
|
||||
local Tabpage = {}
|
||||
Tabpage.__index = Tabpage
|
||||
function Tabpage.new(id) return setmetatable({id=id}, Tabpage) end
|
||||
function Tabpage.new(id)
|
||||
return setmetatable({ id = id }, Tabpage)
|
||||
end
|
||||
|
||||
local Response = {}
|
||||
Response.__index = Response
|
||||
@@ -17,7 +23,7 @@ Response.__index = Response
|
||||
function Response.new(msgpack_rpc_stream, request_id)
|
||||
return setmetatable({
|
||||
_msgpack_rpc_stream = msgpack_rpc_stream,
|
||||
_request_id = request_id
|
||||
_request_id = request_id,
|
||||
}, Response)
|
||||
end
|
||||
|
||||
@@ -41,19 +47,31 @@ function MsgpackRpcStream.new(stream)
|
||||
_stream = stream,
|
||||
_pack = mpack.Packer({
|
||||
ext = {
|
||||
[Buffer] = function(o) return 0, mpack.encode(o.id) end,
|
||||
[Window] = function(o) return 1, mpack.encode(o.id) end,
|
||||
[Tabpage] = function(o) return 2, mpack.encode(o.id) end
|
||||
}
|
||||
[Buffer] = function(o)
|
||||
return 0, mpack.encode(o.id)
|
||||
end,
|
||||
[Window] = function(o)
|
||||
return 1, mpack.encode(o.id)
|
||||
end,
|
||||
[Tabpage] = function(o)
|
||||
return 2, mpack.encode(o.id)
|
||||
end,
|
||||
},
|
||||
}),
|
||||
_session = mpack.Session({
|
||||
unpack = mpack.Unpacker({
|
||||
ext = {
|
||||
[0] = function(_c, s) return Buffer.new(mpack.decode(s)) end,
|
||||
[1] = function(_c, s) return Window.new(mpack.decode(s)) end,
|
||||
[2] = function(_c, s) return Tabpage.new(mpack.decode(s)) end
|
||||
}
|
||||
})
|
||||
[0] = function(_c, s)
|
||||
return Buffer.new(mpack.decode(s))
|
||||
end,
|
||||
[1] = function(_c, s)
|
||||
return Window.new(mpack.decode(s))
|
||||
end,
|
||||
[2] = function(_c, s)
|
||||
return Tabpage.new(mpack.decode(s))
|
||||
end,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}, MsgpackRpcStream)
|
||||
end
|
||||
@@ -67,7 +85,7 @@ function MsgpackRpcStream:write(method, args, response_cb)
|
||||
data = self._session:notify()
|
||||
end
|
||||
|
||||
data = data .. self._pack(method) .. self._pack(args)
|
||||
data = data .. self._pack(method) .. self._pack(args)
|
||||
self._stream:write(data)
|
||||
end
|
||||
|
||||
@@ -80,12 +98,10 @@ function MsgpackRpcStream:read_start(request_cb, notification_cb, eof_cb)
|
||||
local pos = 1
|
||||
local len = #data
|
||||
while pos <= len do
|
||||
type, id_or_cb, method_or_error, args_or_result, pos =
|
||||
self._session:receive(data, pos)
|
||||
type, id_or_cb, method_or_error, args_or_result, pos = self._session:receive(data, pos)
|
||||
if type == 'request' or type == 'notification' then
|
||||
if type == 'request' then
|
||||
request_cb(method_or_error, args_or_result, Response.new(self,
|
||||
id_or_cb))
|
||||
request_cb(method_or_error, args_or_result, Response.new(self, id_or_cb))
|
||||
else
|
||||
notification_cb(method_or_error, args_or_result)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user