diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-12-04 14:32:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 14:32:39 -0800 |
commit | c3836e40a2bffbc1d4e06531145b7825788dd818 (patch) | |
tree | 895e994179074983789a5f893b96dc75d39f6e6b /test/client/msgpack_rpc_stream.lua | |
parent | 45fe4d11add933df76a2ea4bf52ce8904f4a778b (diff) | |
download | rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.tar.gz rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.tar.bz2 rneovim-c3836e40a2bffbc1d4e06531145b7825788dd818.zip |
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: 45fe4d11add933df76a2ea4bf52ce8904f4a778b
previous: 517f0cc634b985057da5b95cf4ad659ee456a77e
Diffstat (limited to 'test/client/msgpack_rpc_stream.lua')
-rw-r--r-- | test/client/msgpack_rpc_stream.lua | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/test/client/msgpack_rpc_stream.lua b/test/client/msgpack_rpc_stream.lua index 5711616b17..ff054ae62b 100644 --- a/test/client/msgpack_rpc_stream.lua +++ b/test/client/msgpack_rpc_stream.lua @@ -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 |