aboutsummaryrefslogtreecommitdiff
path: root/test/client/session.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-12-04 14:32:39 -0800
committerGitHub <noreply@github.com>2023-12-04 14:32:39 -0800
commitc3836e40a2bffbc1d4e06531145b7825788dd818 (patch)
tree895e994179074983789a5f893b96dc75d39f6e6b /test/client/session.lua
parent45fe4d11add933df76a2ea4bf52ce8904f4a778b (diff)
downloadrneovim-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/session.lua')
-rw-r--r--test/client/session.lua28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/client/session.lua b/test/client/session.lua
index b1bf5ea75e..78909d1061 100644
--- a/test/client/session.lua
+++ b/test/client/session.lua
@@ -7,7 +7,7 @@ if package.loaded['jit'] then
-- luajit pcall is already coroutine safe
Session.safe_pcall = pcall
else
- Session.safe_pcall = require'coxpcall'.pcall
+ Session.safe_pcall = require 'coxpcall'.pcall
end
local function resume(co, ...)
@@ -25,7 +25,7 @@ local function resume(co, ...)
end
local function coroutine_exec(func, ...)
- local args = {...}
+ local args = { ... }
local on_complete
if #args > 0 and type(args[#args]) == 'function' then
@@ -50,18 +50,18 @@ function Session.new(stream)
_pending_messages = {},
_prepare = uv.new_prepare(),
_timer = uv.new_timer(),
- _is_running = false
+ _is_running = false,
}, Session)
end
function Session:next_message(timeout)
local function on_request(method, args, response)
- table.insert(self._pending_messages, {'request', method, args, response})
+ table.insert(self._pending_messages, { 'request', method, args, response })
uv.stop()
end
local function on_notification(method, args)
- table.insert(self._pending_messages, {'notification', method, args})
+ table.insert(self._pending_messages, { 'notification', method, args })
uv.stop()
end
@@ -83,11 +83,11 @@ function Session:next_message(timeout)
end
function Session:notify(method, ...)
- self._msgpack_rpc_stream:write(method, {...})
+ self._msgpack_rpc_stream:write(method, { ... })
end
function Session:request(method, ...)
- local args = {...}
+ local args = { ... }
local err, result
if self._is_running then
err, result = self:_yielding_request(method, args)
@@ -141,8 +141,12 @@ function Session:stop()
end
function Session:close(signal)
- if not self._timer:is_closing() then self._timer:close() end
- if not self._prepare:is_closing() then self._prepare:close() end
+ if not self._timer:is_closing() then
+ self._timer:close()
+ end
+ if not self._prepare:is_closing() then
+ self._prepare:close()
+ end
self._msgpack_rpc_stream:close(signal)
self.closed = true
end
@@ -159,11 +163,11 @@ function Session:_blocking_request(method, args)
local err, result
local function on_request(method_, args_, response)
- table.insert(self._pending_messages, {'request', method_, args_, response})
+ table.insert(self._pending_messages, { 'request', method_, args_, response })
end
local function on_notification(method_, args_)
- table.insert(self._pending_messages, {'notification', method_, args_})
+ table.insert(self._pending_messages, { 'notification', method_, args_ })
end
self._msgpack_rpc_stream:write(method, args, function(e, r)
@@ -187,7 +191,7 @@ function Session:_run(request_cb, notification_cb, timeout)
end
self._msgpack_rpc_stream:read_start(request_cb, notification_cb, function()
uv.stop()
- self.eof_err = {1, "EOF was received from Nvim. Likely the Nvim process crashed."}
+ self.eof_err = { 1, 'EOF was received from Nvim. Likely the Nvim process crashed.' }
end)
uv.run()
self._prepare:stop()