Skip to content

Commit 606060e

Browse files
authored
chore!: upgrade commons.nvim library (#251)
docs: remove code coverage badge (#251)
1 parent a221c13 commit 606060e

File tree

14 files changed

+59
-824
lines changed

14 files changed

+59
-824
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
27-
- uses: JohnnyMorganz/stylua-action@v3
27+
- uses: JohnnyMorganz/stylua-action@v4
2828
with:
2929
token: ${{ secrets.GITHUB_TOKEN }}
3030
version: latest
3131
args: --config-path .stylua.toml ./lua ./spec
32-
- uses: mrcjkb/lua-typecheck-action@v0
32+
- uses: stevearc/nvim-typecheck-action@v2
3333
with:
34-
directories: lua
34+
path: lua
3535
configpath: ".luarc.json"
3636
- uses: cargo-bins/cargo-binstall@main
3737
- name: Selene
@@ -59,7 +59,7 @@ jobs:
5959
echo $PWD
6060
git clone --depth=1 https://github.com/linrongbin16/giturlparser.lua.git ~/.giturlparser.lua
6161
cp ~/.giturlparser.lua/src/giturlparser.lua ./lua/gitlinker/giturlparser.lua
62-
- uses: stefanzweifel/git-auto-commit-action@v4
62+
- uses: stefanzweifel/git-auto-commit-action@v5
6363
if: ${{ github.ref != 'refs/heads/master' }}
6464
with:
6565
commit_message: "chore(pr): auto-commit"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# gitlinker.nvim
22

33
<p>
4-
<a href="https://github.com/neovim/neovim/releases/v0.9.0"><img alt="Neovim" src="https://img.shields.io/badge/require-0.9%2B-blue" /></a>
4+
<a href="https://github.com/neovim/neovim/releases/"><img alt="Neovim" src="https://img.shields.io/badge/require-stable-blue" /></a>
55
<a href="https://github.com/linrongbin16/commons.nvim"><img alt="commons.nvim" src="https://img.shields.io/badge/power_by-commons.nvim-pink" /></a>
66
<a href="https://luarocks.org/modules/linrongbin16/gitlinker.nvim"><img alt="luarocks" src="https://img.shields.io/luarocks/v/linrongbin16/gitlinker.nvim" /></a>
77
<a href="https://github.com/linrongbin16/gitlinker.nvim/actions/workflows/ci.yml"><img alt="ci.yml" src="https://img.shields.io/github/actions/workflow/status/linrongbin16/gitlinker.nvim/ci.yml?label=ci" /></a>
8-
<a href="https://app.codecov.io/github/linrongbin16/gitlinker.nvim"><img alt="codecov" src="https://img.shields.io/codecov/c/github/linrongbin16/gitlinker.nvim/main?label=codecov" /></a>
8+
<!-- <a href="https://app.codecov.io/github/linrongbin16/gitlinker.nvim"><img alt="codecov" src="https://img.shields.io/codecov/c/github/linrongbin16/gitlinker.nvim/main?label=codecov" /></a> -->
99
</p>
1010

1111
> Maintained fork of [ruifm's gitlinker](https://github.com/ruifm/gitlinker.nvim), refactored with bug fixes, ssh host alias, blame support and other improvements.
@@ -66,9 +66,9 @@ PRs are welcomed for other git host websites!
6666

6767
> [!NOTE]
6868
>
69-
> This plugin keeps update with the latest stable Neovim version, supports until the last legacy version, while earlier versions are dropped for maintenance reason. For example at the time of writing (2024-08-20), stable is 0.10, last legacy is 0.9. Thus this plugin supports 0.9+.
69+
> This plugin always supports the latest stable and (possible) nightly version.
7070
71-
- Neovim &ge; 0.9.
71+
- Neovim &ge; 0.10.
7272
- [git](https://git-scm.com/).
7373
- [ssh](https://www.openssh.com/) (optional for resolve ssh host alias).
7474
- [wslview](https://github.com/wslutilities/wslu) (optional for open browser from Windows wsl2).

lua/gitlinker.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
local tbl = require("gitlinker.commons.tbl")
22
local str = require("gitlinker.commons.str")
33
local num = require("gitlinker.commons.num")
4-
local async = require("gitlinker.commons.async")
54
local LogLevels = require("gitlinker.commons.logging").LogLevels
65
local logging = require("gitlinker.commons.logging")
76

7+
local async = require("gitlinker.async")
88
local configs = require("gitlinker.configs")
99
local range = require("gitlinker.range")
1010
local linker = require("gitlinker.linker")

lua/gitlinker/commons/async.lua renamed to lua/gitlinker/async.lua

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
-- Store all the async threads in a weak table so we don't prevent them from
66
-- being garbage collected
7-
local handles = setmetatable({}, { __mode = 'k' })
7+
local handles = setmetatable({}, { __mode = "k" })
88

99
local M = {}
1010

@@ -28,10 +28,12 @@ function M.running()
2828
end
2929

3030
local function is_Async_T(handle)
31-
if handle
32-
and type(handle) == 'table'
31+
if
32+
handle
33+
and type(handle) == "table"
3334
and vim.is_callable(handle.cancel)
34-
and vim.is_callable(handle.is_cancelled) then
35+
and vim.is_callable(handle.is_cancelled)
36+
then
3537
return true
3638
end
3739
end
@@ -63,35 +65,36 @@ end
6365
--- @tparam any ... Arguments for func
6466
--- @treturn async_t Handle
6567
function M.run(func, callback, ...)
66-
vim.validate {
67-
func = { func, 'function' },
68-
callback = { callback, 'function', true }
69-
}
68+
vim.validate({
69+
func = { func, "function" },
70+
callback = { callback, "function", true },
71+
})
7072

7173
local co = coroutine.create(func)
7274
local handle = Async_T.new(co)
7375

7476
local function step(...)
75-
local ret = {coroutine.resume(co, ...)}
77+
local ret = { coroutine.resume(co, ...) }
7678
local ok = ret[1]
7779

7880
if not ok then
7981
local err = ret[2]
80-
error(string.format("The coroutine failed with this message:\n%s\n%s",
81-
err, debug.traceback(co)))
82+
error(
83+
string.format("The coroutine failed with this message:\n%s\n%s", err, debug.traceback(co))
84+
)
8285
end
8386

84-
if coroutine.status(co) == 'dead' then
87+
if coroutine.status(co) == "dead" then
8588
if callback then
8689
callback(unpack(ret, 4, table.maxn(ret)))
8790
end
8891
return
8992
end
9093

9194
local nargs, fn = ret[2], ret[3]
92-
local args = {select(4, unpack(ret))}
95+
local args = { select(4, unpack(ret)) }
9396

94-
assert(type(fn) == 'function', "type error :: expected func")
97+
assert(type(fn) == "function", "type error :: expected func")
9598

9699
args[nargs] = step
97100

@@ -106,10 +109,10 @@ function M.run(func, callback, ...)
106109
end
107110

108111
local function wait(argc, func, ...)
109-
vim.validate {
110-
argc = { argc, 'number' },
111-
func = { func, 'function' },
112-
}
112+
vim.validate({
113+
argc = { argc, "number" },
114+
func = { func, "function" },
115+
})
113116

114117
-- Always run the wrapped functions in xpcall and re-raise the error in the
115118
-- coroutine. This makes pcall work as normal.
@@ -124,7 +127,7 @@ local function wait(argc, func, ...)
124127
end, unpack(args, 1, argc))
125128
end
126129

127-
local ret = {coroutine.yield(argc, pfunc, ...)}
130+
local ret = { coroutine.yield(argc, pfunc, ...) }
128131

129132
local ok = ret[1]
130133
if not ok then
@@ -141,12 +144,12 @@ end
141144
--- @tparam function func callback style function to execute
142145
--- @tparam any ... Arguments for func
143146
function M.wait(...)
144-
if type(select(1, ...)) == 'number' then
147+
if type(select(1, ...)) == "number" then
145148
return wait(...)
146149
end
147150

148151
-- Assume argc is equal to the number of passed arguments.
149-
return wait(select('#', ...) - 1, ...)
152+
return wait(select("#", ...) - 1, ...)
150153
end
151154

152155
--- Use this to create a function which executes in an async context but
@@ -157,20 +160,20 @@ end
157160
--- @tparam boolean strict Error when called in non-async context
158161
--- @treturn function(...):async_t
159162
function M.create(func, argc, strict)
160-
vim.validate {
161-
func = { func, 'function' },
162-
argc = { argc, 'number', true }
163-
}
163+
vim.validate({
164+
func = { func, "function" },
165+
argc = { argc, "number", true },
166+
})
164167
argc = argc or 0
165168
return function(...)
166169
if M.running() then
167170
if strict then
168-
error('This function must run in a non-async context')
171+
error("This function must run in a non-async context")
169172
end
170173
return func(...)
171174
end
172175
local callback = select(argc + 1, ...)
173-
return M.run(func, callback, unpack({...}, 1, argc))
176+
return M.run(func, callback, unpack({ ... }, 1, argc))
174177
end
175178
end
176179

@@ -179,11 +182,11 @@ end
179182
--- @tparam function func
180183
--- @tparam boolean strict Error when called in non-async context
181184
function M.void(func, strict)
182-
vim.validate { func = { func, 'function' } }
185+
vim.validate({ func = { func, "function" } })
183186
return function(...)
184187
if M.running() then
185188
if strict then
186-
error('This function must run in a non-async context')
189+
error("This function must run in a non-async context")
187190
end
188191
return func(...)
189192
end
@@ -198,13 +201,13 @@ end
198201
--- @tparam boolean strict Error when called in non-async context
199202
--- @treturn function Returns an async function
200203
function M.wrap(func, argc, strict)
201-
vim.validate {
202-
argc = { argc, 'number' },
203-
}
204+
vim.validate({
205+
argc = { argc, "number" },
206+
})
204207
return function(...)
205208
if not M.running() then
206209
if strict then
207-
error('This function must run in an async context')
210+
error("This function must run in an async context")
208211
end
209212
return func(...)
210213
end
@@ -229,7 +232,7 @@ function M.join(thunks, n, interrupt_check)
229232
local ret = {}
230233

231234
local function cb(...)
232-
ret[#ret + 1] = {...}
235+
ret[#ret + 1] = { ... }
233236
to_go = to_go - 1
234237
if to_go == 0 then
235238
finish(ret)
@@ -256,11 +259,11 @@ end
256259
--- @tparam function fn
257260
--- @param ... arguments to apply to `fn`
258261
function M.curry(fn, ...)
259-
local args = {...}
260-
local nargs = select('#', ...)
262+
local args = { ... }
263+
local nargs = select("#", ...)
261264
return function(...)
262-
local other = {...}
263-
for i = 1, select('#', ...) do
265+
local other = { ... }
266+
for i = 1, select("#", ...) do
264267
args[nargs + i] = other[i]
265268
end
266269
fn(unpack(args))

0 commit comments

Comments
 (0)