Skip to content

Commit 351f010

Browse files
authored
Merge branch 'nvim-lua:master' into scan_symlink
2 parents 771fa46 + 4f71c0c commit 351f010

29 files changed

+413
-142
lines changed

.github/workflows/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- os: ubuntu-22.04
1818
rev: v0.8.3/nvim-linux64.tar.gz
1919
- os: ubuntu-22.04
20-
rev: v0.9.0/nvim-linux64.tar.gz
20+
rev: v0.9.1/nvim-linux64.tar.gz
2121
steps:
2222
- uses: actions/checkout@v3
2323
- run: date +%F > todays-date

.luacheckrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ read_globals = {
2727
exclude_files = {
2828
"lua/plenary/profile/lua_profiler.lua",
2929
"lua/plenary/profile/memory_profiler.lua",
30-
"lua/plenary/vararg/rotate.lua",
3130
"lua/plenary/async_lib/*.lua",
3231
}
3332

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test generate_filetypes lint luarocks_upload test_luarocks_install
22
test:
3-
nvim --headless --noplugin -u scripts/minimal.vim -c "PlenaryBustedDirectory tests/plenary/ {minimal_init = 'tests/minimal_init.vim'}"
3+
nvim --headless --noplugin -u scripts/minimal.vim -c "PlenaryBustedDirectory tests/plenary/ {minimal_init = 'tests/minimal_init.vim', sequential = true}"
44

55
generate_filetypes:
66
nvim --headless -c 'luafile scripts/update_filetypes_from_github.lua' -c 'qa!'

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ use "nvim-lua/plenary.nvim"
2828

2929
## Modules
3030

31-
- `plenary.async`
32-
- `plenary.async_lib`
33-
- `plenary.job`
34-
- `plenary.path`
35-
- `plenary.scandir`
36-
- `plenary.context_manager`
37-
- `plenary.test_harness`
38-
- `plenary.filetype`
39-
- `plenary.strings`
31+
- [plenary.async](#plenaryasync)
32+
- [plenary.async_lib](#plenaryasync_lib)
33+
- [plenary.job](#plenaryjob)
34+
- [plenary.path](#plenarypath)
35+
- [plenary.scandir](#plenaryscandir)
36+
- [plenary.context_manager](#plenarycontext_manager)
37+
- [plenary.test_harness](#plenarytest_harness)
38+
- [plenary.filetype](#plenaryfiletype)
39+
- [plenary.strings](#plenarystrings)
4040

4141
### plenary.async
4242

@@ -99,7 +99,6 @@ end
9999
#### Plugins using this
100100

101101
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
102-
- [gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
103102
- [vgit.nvim](https://github.com/tanvirtin/vgit.nvim)
104103
- [neogit](https://github.com/TimUntersberger/neogit)
105104
- [neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim)

data/plenary/filetypes/builtin.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ return {
3636
['graphql'] = 'graphql',
3737
['hbs'] = 'handlebars',
3838
['hdbs'] = 'handlebars',
39+
['hlsl'] = 'hlsl',
40+
['jai'] = 'jai',
3941
['janet'] = 'janet',
4042
['jl'] = 'julia',
4143
['jsx'] = 'javascriptreact',

lua/plenary/async/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ return setmetatable({}, {
88
util.scheduler()
99
end
1010

11-
vim.api[k](...)
11+
return vim.api[k](...)
1212
end
1313
end,
1414
})

lua/plenary/async/async.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local f = require "plenary.functional"
77
local M = {}
88

99
local function is_callable(fn)
10-
return type(fn) == "function" or type(getmetatable(fn)["__call"]) == "function"
10+
return type(fn) == "function" or (type(fn) == "table" and type(getmetatable(fn)["__call"]) == "function")
1111
end
1212

1313
---because we can't store varargs

lua/plenary/async/control.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function Condvar:notify_all()
3232
callback()
3333
end
3434

35-
for i = 1, len do
35+
for _ = 1, len do
3636
-- table.remove will ensure that indexes are correct and make "ipairs" safe,
3737
-- which is not the case for "self.handles[i] = nil"
38-
table.remove(self.handles, i)
38+
table.remove(self.handles)
3939
end
4040
end
4141

lua/plenary/async/util.lua

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ M.sleep = a.wrap(defer_swapped, 2)
2222
M.block_on = function(async_function, timeout)
2323
async_function = M.protected(async_function)
2424

25-
local stat, ret
25+
local stat
26+
local ret = {}
2627

2728
a.run(async_function, function(stat_, ...)
2829
stat = stat_
@@ -75,14 +76,14 @@ M.join = function(async_fns)
7576
return results
7677
end
7778

78-
---Returns a future that when run will select the first async_function that finishes
79-
---@param async_funs table: The async_function that you want to select
79+
---Returns a result from the future that finishes at the first
80+
---@param async_functions table: The futures that you want to select
8081
---@return ...
81-
M.run_first = a.wrap(function(async_funs, step)
82+
M.run_first = a.wrap(function(async_functions, step)
8283
local ran = false
8384

84-
for _, future in ipairs(async_funs) do
85-
assert(type(future) == "function", "type error :: future must be function")
85+
for _, async_function in ipairs(async_functions) do
86+
assert(type(async_function) == "function", "type error :: future must be function")
8687

8788
local callback = function(...)
8889
if not ran then
@@ -91,10 +92,22 @@ M.run_first = a.wrap(function(async_funs, step)
9192
end
9293
end
9394

94-
future(callback)
95+
async_function(callback)
9596
end
9697
end, 2)
9798

99+
---Returns a result from the functions that finishes at the first
100+
---@param funcs table: The async functions that you want to select
101+
---@return ...
102+
M.race = function(funcs)
103+
local async_functions = vim.tbl_map(function(func)
104+
return function(callback)
105+
a.run(func, callback)
106+
end
107+
end, funcs)
108+
return M.run_first(async_functions)
109+
end
110+
98111
M.run_all = function(async_fns, callback)
99112
a.run(function()
100113
M.join(async_fns)

lua/plenary/busted.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ local pop_description = function()
5959
end
6060

6161
local add_new_each = function()
62-
current_before_each[current_description[#current_description]] = {}
63-
current_after_each[current_description[#current_description]] = {}
62+
current_before_each[#current_description] = {}
63+
current_after_each[#current_description] = {}
6464
end
6565

6666
local clear_last_each = function()
67-
current_before_each[current_description[#current_description]] = nil
68-
current_after_each[current_description[#current_description]] = nil
67+
current_before_each[#current_description] = nil
68+
current_after_each[#current_description] = nil
6969
end
7070

7171
local call_inner = function(desc, func)
@@ -140,11 +140,11 @@ mod.inner_describe = function(desc, func)
140140
end
141141

142142
mod.before_each = function(fn)
143-
table.insert(current_before_each[current_description[#current_description]], fn)
143+
table.insert(current_before_each[#current_description], fn)
144144
end
145145

146146
mod.after_each = function(fn)
147-
table.insert(current_after_each[current_description[#current_description]], fn)
147+
table.insert(current_after_each[#current_description], fn)
148148
end
149149

150150
mod.clear = function()
@@ -161,7 +161,7 @@ local indent = function(msg, spaces)
161161
end
162162

163163
local run_each = function(tbl)
164-
for _, v in pairs(tbl) do
164+
for _, v in ipairs(tbl) do
165165
for _, w in ipairs(v) do
166166
if type(w) == "function" then
167167
w()
@@ -215,6 +215,8 @@ clear = mod.clear
215215
assert = require "luassert"
216216

217217
mod.run = function(file)
218+
file = file:gsub("\\", "/")
219+
218220
print("\n" .. HEADER)
219221
print("Testing: ", file)
220222

0 commit comments

Comments
 (0)