aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/paq.lua3
-rw-r--r--lua/paq/compat.lua52
2 files changed, 1 insertions, 54 deletions
diff --git a/lua/paq.lua b/lua/paq.lua
index d69c4cd..0396802 100644
--- a/lua/paq.lua
+++ b/lua/paq.lua
@@ -1,4 +1,3 @@
1local vim = vim.api.nvim_call_function("has", {"nvim-0.5"}) and vim or require("paq.compat")
2local uv = vim.loop 1local uv = vim.loop
3local print_err = vim.api.nvim_err_writeln 2local print_err = vim.api.nvim_err_writeln
4 3
@@ -89,7 +88,7 @@ end
89 88
90local function install(pkg) 89local function install(pkg)
91 if pkg.exists then return update_count("install", "nop", nil, num_pkgs) end 90 if pkg.exists then return update_count("install", "nop", nil, num_pkgs) end
92 local args = {"clone", pkg.url, "--depth=1", "--recurse-submodules", "--shallow-submodules"} 91 local args = {"clone", pkg.url, "--recurse-submodules"}
93 if pkg.branch then vim.list_extend(args, {"-b", pkg.branch}) end 92 if pkg.branch then vim.list_extend(args, {"-b", pkg.branch}) end
94 vim.list_extend(args, {pkg.dir}) 93 vim.list_extend(args, {pkg.dir})
95 local post_install = function(ok) 94 local post_install = function(ok)
diff --git a/lua/paq/compat.lua b/lua/paq/compat.lua
deleted file mode 100644
index 1df6583..0000000
--- a/lua/paq/compat.lua
+++ /dev/null
@@ -1,52 +0,0 @@
1-- Functions for nvim 0.4 compatibility.
2-- This module will be removed once nvim 0.5 becomes stable.
3
4local fn = setmetatable({}, {
5 __index = function(_, key)
6 return function(...)
7 return vim.api.nvim_call_function(key, {...})
8 end
9 end}
10)
11
12local function tbl_map(func, t)
13 local rettab = {}
14 for k, v in pairs(t) do
15 rettab[k] = func(v)
16 end
17 return rettab
18end
19
20local function tbl_keys(t)
21 local rettab = {}
22 for k, _ in pairs(t) do
23 table.insert(rettab, k)
24 end
25 return rettab
26end
27
28local function tbl_filter(func, t)
29 local rettab = {}
30 for _, v in pairs(t) do
31 if func(v) then
32 table.insert(rettab, v)
33 end
34 end
35 return rettab
36end
37
38local function list_extend(dst, src, start, finish)
39 for i = start or 1, finish or #src do
40 table.insert(dst, src[i])
41 end
42 return dst
43end
44
45return setmetatable({
46 fn = fn,
47 cmd = vim.api.nvim_command,
48 tbl_map = tbl_map,
49 tbl_keys = tbl_keys,
50 tbl_filter = tbl_filter,
51 list_extend = list_extend,
52}, {__index=function(self, key) return vim[key] or self[key] end})