Skip to content

Commit af24091

Browse files
authored
Fix luacheck issues (neovim#42)
1 parent c10c0b7 commit af24091

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

.luacheckrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Don't report unused self arguments of methods.
2+
self = false
3+
4+
ignore = {
5+
"212/_.*", -- unused argument, for vars with "_" prefix
6+
}
7+
8+
-- vim: ft=lua tw=80 sw=2 et

nvim/msgpack_rpc_stream.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ function MsgpackRpcStream.new(stream)
4949
_session = mpack.Session({
5050
unpack = mpack.Unpacker({
5151
ext = {
52-
[0] = function(c, s) return Buffer.new(mpack.unpack(s)) end,
53-
[1] = function(c, s) return Window.new(mpack.unpack(s)) end,
54-
[2] = function(c, s) return Tabpage.new(mpack.unpack(s)) end
52+
[0] = function(_c, s) return Buffer.new(mpack.unpack(s)) end,
53+
[1] = function(_c, s) return Window.new(mpack.unpack(s)) end,
54+
[2] = function(_c, s) return Tabpage.new(mpack.unpack(s)) end
5555
}
5656
})
5757
}),
@@ -76,7 +76,7 @@ function MsgpackRpcStream:read_start(request_cb, notification_cb, eof_cb)
7676
if not data then
7777
return eof_cb()
7878
end
79-
local type, id_or_cb
79+
local type, id_or_cb, method_or_error, args_or_result
8080
local pos = 1
8181
local len = #data
8282
while pos <= len do

nvim/session.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require('coxpcall')
1+
local coxpcall = require('coxpcall')
22
local uv = require('luv')
33
local MsgpackRpcStream = require('nvim.msgpack_rpc_stream')
44

@@ -30,7 +30,7 @@ local function coroutine_exec(func, ...)
3030
end
3131

3232
resume(coroutine.create(function()
33-
local status, result, flag = copcall(func, unpack(args))
33+
local status, result, flag = coxpcall.pcall(func, unpack(args))
3434
if on_complete then
3535
coroutine.yield(function()
3636
-- run the completion callback on the main thread
@@ -148,12 +148,12 @@ end
148148
function Session:_blocking_request(method, args)
149149
local err, result
150150

151-
local function on_request(method, args, response)
152-
table.insert(self._pending_messages, {'request', method, args, response})
151+
local function on_request(method_, args_, response)
152+
table.insert(self._pending_messages, {'request', method_, args_, response})
153153
end
154154

155-
local function on_notification(method, args)
156-
table.insert(self._pending_messages, {'notification', method, args})
155+
local function on_notification(method_, args_)
156+
table.insert(self._pending_messages, {'notification', method_, args_})
157157
end
158158

159159
self._msgpack_rpc_stream:write(method, args, function(e, r)

test/session_spec.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ do
1515
socket_file = string.format("/tmp/nvim.socket-%d", math.random(1000,9999))
1616
end
1717

18-
function test_session(description, session_factory, session_destroy)
18+
local function test_session(description, session_factory, session_destroy)
1919
local get_api_info = function (session)
2020
local ok, res = session:request('vim_get_api_info')
2121
return ok, unpack(res)
@@ -112,7 +112,7 @@ function test_session(description, session_factory, session_destroy)
112112
local requested = 0
113113
local _, channel_id, _ = get_api_info(session)
114114

115-
local function on_request(method, args)
115+
local function on_request(method)
116116
assert.are.same("method", method)
117117
requested = requested + 1
118118
if requested < 10 then

0 commit comments

Comments
 (0)