diff options
-rw-r--r-- | lua/paq.lua | 3 | ||||
-rw-r--r-- | lua/paq/compat.lua | 52 |
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 @@ | |||
1 | local vim = vim.api.nvim_call_function("has", {"nvim-0.5"}) and vim or require("paq.compat") | ||
2 | local uv = vim.loop | 1 | local uv = vim.loop |
3 | local print_err = vim.api.nvim_err_writeln | 2 | local print_err = vim.api.nvim_err_writeln |
4 | 3 | ||
@@ -89,7 +88,7 @@ end | |||
89 | 88 | ||
90 | local function install(pkg) | 89 | local 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 | |||
4 | local fn = setmetatable({}, { | ||
5 | __index = function(_, key) | ||
6 | return function(...) | ||
7 | return vim.api.nvim_call_function(key, {...}) | ||
8 | end | ||
9 | end} | ||
10 | ) | ||
11 | |||
12 | local 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 | ||
18 | end | ||
19 | |||
20 | local function tbl_keys(t) | ||
21 | local rettab = {} | ||
22 | for k, _ in pairs(t) do | ||
23 | table.insert(rettab, k) | ||
24 | end | ||
25 | return rettab | ||
26 | end | ||
27 | |||
28 | local 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 | ||
36 | end | ||
37 | |||
38 | local 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 | ||
43 | end | ||
44 | |||
45 | return 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}) | ||