Refresh generated neovim config
This commit is contained in:
@ -46,10 +46,10 @@ jobs:
|
||||
name: Install Neovim on Macos
|
||||
run: |
|
||||
cd
|
||||
curl -LO https://github.com/neovim/neovim/releases/download/${{ matrix.version }}/nvim-macos-x86_64.tar.gz
|
||||
tar xzf nvim-macos-x86_64.tar.gz
|
||||
echo "${PWD}/nvim-macos-x86_64/bin" >> $GITHUB_PATH
|
||||
export PATH="${PWD}/nvim-macos-x86_64/bin:${PATH}"
|
||||
curl -LO https://github.com/neovim/neovim/releases/download/${{ matrix.version }}/nvim-macos-arm64.tar.gz
|
||||
tar xzf nvim-macos-arm64.tar.gz
|
||||
echo "${PWD}/nvim-macos-arm64/bin" >> $GITHUB_PATH
|
||||
export PATH="${PWD}/nvim-macos-arm64/bin:${PATH}"
|
||||
nvim -v
|
||||
|
||||
- name: Run Test
|
||||
|
||||
@ -12,10 +12,6 @@ LUA_NUMBER := $(word 2,$(LUA_VERSION))
|
||||
TARGET_DIR := $(DEPS)/$(LUA_NUMBER)
|
||||
|
||||
HEREROCKS ?= $(DEPS)/hererocks.py
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
HEREROCKS_ENV ?= MACOSX_DEPLOYMENT_TARGET=10.15
|
||||
endif
|
||||
HEREROCKS_URL ?= https://raw.githubusercontent.com/luarocks/hererocks/master/hererocks.py
|
||||
HEREROCKS_ACTIVE := source $(TARGET_DIR)/bin/activate
|
||||
|
||||
@ -53,7 +49,7 @@ $(HEREROCKS):
|
||||
curl $(HEREROCKS_URL) -o $@
|
||||
|
||||
$(LUAROCKS): $(HEREROCKS)
|
||||
$(HEREROCKS_ENV) python $< $(TARGET_DIR) --$(LUA_VERSION) -r latest
|
||||
$(HEREROCKS_ENV) python3 $< $(TARGET_DIR) --$(LUA_VERSION) -r latest
|
||||
|
||||
$(BUSTED): $(LUAROCKS)
|
||||
$(HEREROCKS_ACTIVE) && luarocks install busted
|
||||
|
||||
@ -8,63 +8,89 @@ local Error = {_id = errorId}
|
||||
Error.__index = Error
|
||||
|
||||
local function dump(o, limit)
|
||||
local s
|
||||
if type(o) ~= 'table' then
|
||||
s = tostring(o)
|
||||
else
|
||||
local meta = getmetatable(o)
|
||||
if meta and meta.__tostring then
|
||||
s = tostring(o)
|
||||
else
|
||||
if limit > 0 then
|
||||
local fmt = '%s [%s] = %s,'
|
||||
s = '{'
|
||||
for k, v in pairs(o) do
|
||||
if type(k) ~= 'number' then
|
||||
k = '"' .. k .. '"'
|
||||
end
|
||||
s = fmt:format(s, k, dump(v, limit - 1))
|
||||
end
|
||||
s = s:sub(1, #s - 1) .. ' }'
|
||||
else
|
||||
s = '{...}'
|
||||
end
|
||||
end
|
||||
local typ = type(o)
|
||||
if typ == 'string' then
|
||||
return o
|
||||
elseif typ ~= 'table' then
|
||||
return tostring(o)
|
||||
end
|
||||
local meta = getmetatable(o)
|
||||
if meta and meta.__tostring then
|
||||
return tostring(o)
|
||||
end
|
||||
if limit > 0 then
|
||||
local fmt = '%s [%s] = %s,'
|
||||
local s = '{'
|
||||
for k, v in pairs(o) do
|
||||
if type(k) ~= 'number' then
|
||||
k = '"' .. k .. '"'
|
||||
end
|
||||
s = fmt:format(s, k, dump(v, limit - 1))
|
||||
end
|
||||
return #s == 1 and '{}' or s:sub(1, #s - 1) .. ' }'
|
||||
else
|
||||
return '{...}'
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function Error.isInstance(o)
|
||||
return type(o) == 'table' and o._id == errorId
|
||||
end
|
||||
|
||||
---@param thread? thread
|
||||
---@param level number
|
||||
---@param skipShortSrc? string
|
||||
---@return string?
|
||||
function Error.format(thread, level, skipShortSrc)
|
||||
local res
|
||||
local dInfo = thread and debug.getinfo(thread, level, 'nSl') or debug.getinfo(level, 'nSl')
|
||||
if dInfo then
|
||||
local name, shortSrc, currentline = dInfo.name, dInfo.short_src, dInfo.currentline
|
||||
if skipShortSrc == shortSrc then
|
||||
return
|
||||
end
|
||||
local detail
|
||||
if not name or name == '' then
|
||||
detail = ('in function <Anonymous:%d>'):format(dInfo.linedefined)
|
||||
else
|
||||
detail = ([[in function '%s']]):format(name)
|
||||
end
|
||||
res = (' %s:%d: %s'):format(shortSrc, currentline, detail)
|
||||
local what = _G._VERSION:sub(-3) == '5.1' and 'Snl' or 'Slnt'
|
||||
|
||||
local function outputLevelInfo(dInfo)
|
||||
local seg = {('\t%s:'):format(dInfo.short_src)}
|
||||
if dInfo.currentline > 0 then
|
||||
table.insert(seg, ('%d:'):format(dInfo.currentline))
|
||||
end
|
||||
return res
|
||||
-- TODO
|
||||
-- lua 5.3 and 5.4 will look up global function and module function before checking 'namewhat'.
|
||||
-- And insert "in namewhat name" if not found
|
||||
if dInfo.namewhat ~= '' then
|
||||
table.insert(seg, (" in function '%s'"):format(dInfo.name))
|
||||
else
|
||||
if dInfo.what == 'm' then
|
||||
table.insert(seg, ' in main chunk')
|
||||
elseif dInfo.what ~= 'C' then
|
||||
table.insert(seg, (' in function <%s:%d>'):format(dInfo.short_src, dInfo.linedefined))
|
||||
else
|
||||
table.insert(seg, '?')
|
||||
end
|
||||
end
|
||||
if dInfo.istailcall then
|
||||
table.insert(seg, '\n\t(...tail calls...)')
|
||||
end
|
||||
return table.concat(seg, '')
|
||||
end
|
||||
|
||||
---@param startLevel? number
|
||||
---@param skipShortSrc? string
|
||||
---@param doPop? boolean
|
||||
---@return PromiseAsyncError
|
||||
function Error:buildStack(startLevel, skipShortSrc, doPop)
|
||||
local level = startLevel or 1
|
||||
local value
|
||||
local thread = coroutine.running()
|
||||
while true do
|
||||
local dInfo = thread and debug.getinfo(thread, level, what) or debug.getinfo(level, what)
|
||||
if not dInfo or skipShortSrc == dInfo.short_src then
|
||||
break
|
||||
end
|
||||
value = outputLevelInfo(dInfo)
|
||||
level = level + 1
|
||||
self:push(value)
|
||||
end
|
||||
if doPop then
|
||||
self:pop()
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
---@param err any
|
||||
---@return PromiseAsyncError
|
||||
function Error.new(err)
|
||||
local o = setmetatable({}, Error)
|
||||
function Error:new(err)
|
||||
local o = setmetatable({}, self)
|
||||
o.err = err
|
||||
o.queue = {}
|
||||
o.index = 0
|
||||
@ -107,6 +133,11 @@ function Error:push(value)
|
||||
return #self.queue
|
||||
end
|
||||
|
||||
---@return string
|
||||
function Error:pop()
|
||||
return table.remove(self.queue)
|
||||
end
|
||||
|
||||
---@return any
|
||||
function Error:peek()
|
||||
return self.err
|
||||
|
||||
@ -37,6 +37,8 @@ local function runTick()
|
||||
else
|
||||
EventLoop.tickStarted = false
|
||||
end
|
||||
-- luv loop has invoked close method if the timer has finished
|
||||
-- EventLoop.tick:close()
|
||||
end
|
||||
|
||||
function EventLoop.nextTick(callback)
|
||||
@ -53,11 +55,9 @@ local function runIdle()
|
||||
for _, cb in ipairs(callbacks) do
|
||||
EventLoop.callWrapper(cb)
|
||||
end
|
||||
if #EventLoop.idleCallbacks > 0 then
|
||||
EventLoop.idle:start(runIdle)
|
||||
else
|
||||
EventLoop.idle:stop()
|
||||
if #EventLoop.idleCallbacks == 0 then
|
||||
EventLoop.idleStarted = false
|
||||
EventLoop.idle:stop()
|
||||
end
|
||||
end
|
||||
|
||||
@ -73,13 +73,8 @@ end
|
||||
if vim and type(vim.schedule) == 'function' then
|
||||
EventLoop.callWrapper = vim.schedule
|
||||
else
|
||||
function EventLoop.callWrapper(fn)
|
||||
local ok, res = pcall(fn)
|
||||
if not ok then
|
||||
-- luv can't handle object with __tostring filed
|
||||
error(tostring(res))
|
||||
end
|
||||
end
|
||||
-- https://github.com/luvit/luv/pull/665 can throw the non-string error since 1.46 version
|
||||
function EventLoop.callWrapper(fn) fn() end
|
||||
end
|
||||
|
||||
return EventLoop
|
||||
|
||||
@ -87,22 +87,6 @@ local function getThenable(o, typ)
|
||||
return thenCall
|
||||
end
|
||||
|
||||
---@param err any
|
||||
---@return PromiseAsyncError
|
||||
local function buildError(err)
|
||||
local o = errFactory.new(err)
|
||||
local level = 4
|
||||
local value
|
||||
local thread = coroutine.running()
|
||||
repeat
|
||||
value = errFactory.format(thread, level, shortSrc)
|
||||
level = level + 1
|
||||
o:push(value)
|
||||
until not value
|
||||
table.remove(o.queue)
|
||||
return o
|
||||
end
|
||||
|
||||
local resolvePromise, rejectPromise
|
||||
|
||||
---@param promise Promise
|
||||
@ -139,7 +123,10 @@ local function handleQueue(promise)
|
||||
return func(result)
|
||||
end, function(errmsg)
|
||||
if type(errmsg) == 'string' then
|
||||
newPromise.err = buildError(errmsg)
|
||||
-- pop xpcall stack
|
||||
newPromise.err = errFactory:new(errmsg)
|
||||
:buildStack(3, shortSrc, true)
|
||||
return tostring(newPromise.err)
|
||||
end
|
||||
return errmsg
|
||||
end)
|
||||
@ -194,7 +181,10 @@ local function wrapExecutor(promise, executor, self)
|
||||
end
|
||||
end, function(errmsg)
|
||||
if type(errmsg) == 'string' then
|
||||
promise.err = buildError(errmsg)
|
||||
-- pop xpcall stack
|
||||
promise.err = errFactory:new(errmsg)
|
||||
:buildStack(3, shortSrc, true)
|
||||
return tostring(promise.err)
|
||||
end
|
||||
return errmsg
|
||||
end)
|
||||
@ -212,7 +202,7 @@ local function handleRejection(promise)
|
||||
promise.needHandleRejection = nil
|
||||
local err = promise.err
|
||||
if not err then
|
||||
err = errFactory.new(promise.result)
|
||||
err = errFactory:new(promise.result)
|
||||
end
|
||||
err:unshift('UnhandledPromiseRejection with the reason:')
|
||||
error(err)
|
||||
|
||||
@ -20,7 +20,11 @@ Basic['`string`'] = function()
|
||||
end
|
||||
|
||||
Basic['a metatable'] = function()
|
||||
return setmetatable({}, {})
|
||||
return setmetatable({}, {
|
||||
__tostring = function()
|
||||
return '{}'
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
Basic['a thread'] = function()
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
local M = {}
|
||||
local promise = require('promise')
|
||||
local reject = promise.reject
|
||||
|
||||
promise.reject = function (reason)
|
||||
local p = reject(reason)
|
||||
p.needHandleRejection = nil
|
||||
return p
|
||||
end
|
||||
|
||||
M.setTimeout = promise.loop.setTimeout
|
||||
|
||||
|
||||
@ -18,12 +18,7 @@ return function(options)
|
||||
if ok then
|
||||
return
|
||||
end
|
||||
-- Some tests never handle the rejected promises, We should ignore them.
|
||||
local msg = tostring(res)
|
||||
if msg:match('^UnhandledPromiseRejection') then
|
||||
return
|
||||
end
|
||||
table.insert(promiseUnhandledError, msg)
|
||||
table.insert(promiseUnhandledError, tostring(res))
|
||||
end
|
||||
return handler
|
||||
end
|
||||
|
||||
@ -69,6 +69,23 @@ describe('EventLoop for Promise.', function()
|
||||
assert.True(wait())
|
||||
end)
|
||||
|
||||
it('call `nextIdle` in `nextIdle` event', function()
|
||||
local onIdle = spy.new(function() end)
|
||||
local onNextIdle = spy.new(function() end)
|
||||
loop.nextIdle(function()
|
||||
onIdle()
|
||||
loop.nextIdle(function()
|
||||
onNextIdle()
|
||||
assert.spy(onNextIdle).was_called()
|
||||
done()
|
||||
end)
|
||||
assert.spy(onIdle).was_called()
|
||||
assert.spy(onNextIdle).was_not_called()
|
||||
end)
|
||||
|
||||
assert.True(wait())
|
||||
end)
|
||||
|
||||
it('override callWrapper method', function()
|
||||
local rawCallWrapper = loop.callWrapper
|
||||
local callback = function() end
|
||||
|
||||
Reference in New Issue
Block a user