aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Orwe <Brian.orwe@gmail.com>2021-08-16 18:30:26 +0530
committerGitHub <noreply@github.com>2021-08-16 18:30:26 +0530
commit02697e57ffc4947303b07441779e632759f06bf1 (patch)
tree0fec85a442388f31b29f3efbe08073a3487334e0
parent88eba05b96be65c645cb4a45a770c824d80c8d70 (diff)
parentd28f9c5c0d6a7f600e765463e60caa4294201053 (diff)
downloadpaq-02697e57ffc4947303b07441779e632759f06bf1.tar.gz
Merge branch 'savq:master' into fix1
-rw-r--r--README.md14
-rw-r--r--doc/paq-nvim.txt19
-rw-r--r--lua/paq.lua17
3 files changed, 38 insertions, 12 deletions
diff --git a/README.md b/README.md
index 13bc098..014349f 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,20 @@ For Windows:
32git clone https://github.com/savq/paq-nvim.git "$env:LOCALAPPDATA\nvim-data\site\pack\paqs\start\paq-nvim" 32git clone https://github.com/savq/paq-nvim.git "$env:LOCALAPPDATA\nvim-data\site\pack\paqs\start\paq-nvim"
33``` 33```
34 34
35## Bootstrapping
36
37Add the following snippet before your first usage of `paq-nvim` if you want to automatically
38install `paq-nvim`.
39
40```lua
41local fn = vim.fn
42
43local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
44
45if fn.empty(fn.glob(install_path)) > 0 then
46 fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path})
47end
48```
35 49
36## Usage 50## Usage
37 51
diff --git a/doc/paq-nvim.txt b/doc/paq-nvim.txt
index aa18f15..aebe16a 100644
--- a/doc/paq-nvim.txt
+++ b/doc/paq-nvim.txt
@@ -1,4 +1,4 @@
1*paq-nvim.txt* Package manager for Neovim v0.4.4 Last change: 2021-07-07 1*paq-nvim.txt* Package manager for Neovim >= v0.4.4. Last change: 2021-08-13
2*paq-nvim* 2*paq-nvim*
3*paq* 3*paq*
4 4
@@ -13,7 +13,6 @@ CONTENTS *paq-contents*
13 Usage |paq-usage| 13 Usage |paq-usage|
14 Functions and Commands |paq-commands| 14 Functions and Commands |paq-commands|
15 Package options |paq-options| 15 Package options |paq-options|
16 Commands |paq-commands|
17 Paq directory |paq-dir| 16 Paq directory |paq-dir|
18 Paq log |paq-log| 17 Paq log |paq-log|
19 Troubleshooting |paq-troubleshooting| 18 Troubleshooting |paq-troubleshooting|
@@ -99,13 +98,16 @@ imported as `paq`, the functions are:
99|paq.install| *paq.install* 98|paq.install| *paq.install*
100 *:PaqInstall* 99 *:PaqInstall*
101 Installs all packages listed on your configuration, if a package is already 100 Installs all packages listed on your configuration, if a package is already
102 installed, the function ignores it. 101 installed, the function ignores it. If a package has a `run` argument, it'll
102 be executed after a package is installed.
103 103
104 104
105|paq.update| *paq.update* 105|paq.update| *paq.update*
106 *:PaqUpdate* 106 *:PaqUpdate*
107 Updates the installed packages listed on your configuration. If a package 107 Updates the installed packages listed on your configuration. If a package
108 hasn't been installed with |PaqInstall|, the function ignores it. 108 hasn't been installed with |PaqInstall|, the function ignores it.
109 If a package had changes and it has a `run` argument, then the `run`
110 argument will be executed.
109 111
110 112
111|paq.clean| *paq.clean* 113|paq.clean| *paq.clean*
@@ -121,6 +123,13 @@ imported as `paq`, the functions are:
121 out of order. 123 out of order.
122 124
123 125
126|paq.run_hooks| *paq.run_hooks*
127 *:PaqRunHooks*
128 Executes all `run` hooks (functions and shell commands). This can be used
129 when a hook fails, to run a hook without a package having changed, or for
130 other debugging purposes.
131
132
124|paq.list| *paq.list* 133|paq.list| *paq.list*
125 *:PaqList* 134 *:PaqList*
126 Lists installed packages as well as packages that were recently removed. 135 Lists installed packages as well as packages that were recently removed.
@@ -138,7 +147,7 @@ imported as `paq`, the functions are:
138 Deletes the |paq-log| file. 147 Deletes the |paq-log| file.
139 148
140 149
141|paq.setup| *paq:setup* 150|paq:setup| *paq:setup*
142 151
143 Method to configure specific global behavior. It can take a table with the 152 Method to configure specific global behavior. It can take a table with the
144 following keys: 153 following keys:
@@ -157,7 +166,7 @@ imported as `paq`, the functions are:
157 166
158 Default value: `true` 167 Default value: `true`
159 168
160 Note that unlike most Lua plugins, paq.setup is a method, not a function. 169 Note that unlike most Lua plugins, paq:setup is a method, not a function.
161 This allows chaining it with the list of packages without needing to 170 This allows chaining it with the list of packages without needing to
162 bind `"paq"` locally, for example: 171 bind `"paq"` locally, for example:
163> 172>
diff --git a/lua/paq.lua b/lua/paq.lua
index 73a1489..ac6bab0 100644
--- a/lua/paq.lua
+++ b/lua/paq.lua
@@ -26,7 +26,7 @@ local messages = {
26 err = "failed to remove %s", 26 err = "failed to remove %s",
27 }, 27 },
28 hook = { 28 hook = {
29 ok = "ran hook for %s (%s)", 29 ok = "ran hook for %s",
30 err = "failed to run hook for %s", 30 err = "failed to run hook for %s",
31 } 31 }
32} 32}
@@ -51,7 +51,7 @@ local function report(op, result, name, total)
51 local count = cur and string.format("%d/%d", cur, total) or "" 51 local count = cur and string.format("%d/%d", cur, total) or ""
52 local msg = messages[op][result] 52 local msg = messages[op][result]
53 local p = result == "err" and print_err or print 53 local p = result == "err" and print_err or print
54 p(string.format("Paq [%s] " .. msg, count, name, hook)) 54 p(string.format("Paq [%s] " .. msg, count, name))
55end 55end
56 56
57local function call_proc(process, args, cwd, cb) 57local function call_proc(process, args, cwd, cb)
@@ -61,7 +61,7 @@ local function call_proc(process, args, cwd, cb)
61 stderr:open(log) 61 stderr:open(log)
62 handle = uv.spawn( 62 handle = uv.spawn(
63 process, 63 process,
64 {args = args, cwd = cwd, stdio = {nil, nil, stderr}}, 64 {args=args, cwd=cwd, stdio={nil, nil, stderr}, env={"GIT_TERMINAL_PROMPT=0"}},
65 vim.schedule_wrap(function(code) 65 vim.schedule_wrap(function(code)
66 uv.fs_close(log) 66 uv.fs_close(log)
67 stderr:close() 67 stderr:close()
@@ -89,9 +89,9 @@ end
89 89
90local function install(pkg) 90local function install(pkg)
91 if pkg.exists then return update_count("install", "nop", nil, num_pkgs) end 91 if pkg.exists then return update_count("install", "nop", nil, num_pkgs) end
92 local args = pkg.branch 92 local args = {"clone", pkg.url, "--depth=1", "--recurse-submodules", "--shallow-submodules"}
93 and {"clone", pkg.url, "--depth=1", "-b", pkg.branch, pkg.dir} 93 if pkg.branch then vim.list_extend(args, {"-b", pkg.branch}) end
94 or {"clone", pkg.url, "--depth=1", pkg.dir} 94 vim.list_extend(args, {pkg.dir})
95 local post_install = function(ok) 95 local post_install = function(ok)
96 if ok then 96 if ok then
97 pkg.exists = true 97 pkg.exists = true
@@ -130,7 +130,7 @@ local function update(pkg)
130 (cfg.verbose and report or update_count)("update", "nop", pkg.name, num_pkgs) -- blursed 130 (cfg.verbose and report or update_count)("update", "nop", pkg.name, num_pkgs) -- blursed
131 end 131 end
132 end 132 end
133 call_proc("git", {"pull"}, pkg.dir, post_update) 133 call_proc("git", {"pull", "--recurse-submodules", "--update-shallow"}, pkg.dir, post_update)
134end 134end
135 135
136local function remove(packdir) 136local function remove(packdir)
@@ -158,6 +158,7 @@ local function remove(packdir)
158 end 158 end
159end 159end
160 160
161
161local function list() 162local function list()
162 local installed = vim.tbl_filter(function(name) return packages[name].exists end, vim.tbl_keys(packages)) 163 local installed = vim.tbl_filter(function(name) return packages[name].exists end, vim.tbl_keys(packages))
163 local removed = vim.tbl_filter(function(name) return last_ops[name] == "remove" end, vim.tbl_keys(last_ops)) 164 local removed = vim.tbl_filter(function(name) return last_ops[name] == "remove" end, vim.tbl_keys(last_ops))
@@ -211,6 +212,7 @@ do
211 "command! PaqInstall lua require('paq'):install()", 212 "command! PaqInstall lua require('paq'):install()",
212 "command! PaqUpdate lua require('paq'):update()", 213 "command! PaqUpdate lua require('paq'):update()",
213 "command! PaqClean lua require('paq'):clean()", 214 "command! PaqClean lua require('paq'):clean()",
215 "command! PaqRunHooks lua require('paq'):run_hooks()",
214 "command! PaqSync lua require('paq'):sync()", 216 "command! PaqSync lua require('paq'):sync()",
215 "command! PaqList lua require('paq').list()", 217 "command! PaqList lua require('paq').list()",
216 "command! PaqLogOpen lua require('paq').log_open()", 218 "command! PaqLogOpen lua require('paq').log_open()",
@@ -224,6 +226,7 @@ return setmetatable({
224 update = function(self) Counter "update" vim.tbl_map(update, packages) return self end, 226 update = function(self) Counter "update" vim.tbl_map(update, packages) return self end,
225 clean = function(self) Counter "remove" remove(cfg.paqdir .. "start/") remove(cfg.paqdir .. "opt/") return self end, 227 clean = function(self) Counter "remove" remove(cfg.paqdir .. "start/") remove(cfg.paqdir .. "opt/") return self end,
226 sync = function(self) self:clean():update():install() return self end, 228 sync = function(self) self:clean():update():install() return self end,
229 run_hooks = function(self) vim.tbl_map(run_hook, packages) return self end,
227 list = list, 230 list = list,
228 setup = function(self, args) for k,v in pairs(args) do cfg[k] = v end return self end, 231 setup = function(self, args) for k,v in pairs(args) do cfg[k] = v end return self end,
229 log_open = function(self) vim.cmd("sp " .. LOGFILE) return self end, 232 log_open = function(self) vim.cmd("sp " .. LOGFILE) return self end,