-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcurl.lua
More file actions
45 lines (42 loc) · 1.08 KB
/
curl.lua
File metadata and controls
45 lines (42 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local outfmt = "\n┌─────────────────────────\n"
.. "│ dnslookup : %{time_namelookup}\n"
.. "│ connect : %{time_connect}\n"
.. "│ appconnect : %{time_appconnect}\n"
.. "│ pretransfer : %{time_pretransfer}\n"
.. "│ starttransfer : %{time_starttransfer}\n"
.. "│ total : %{time_total}\n"
.. "│ size : %{size_download}\n"
.. "│ HTTPCode=%{http_code}\n\n"
local M = {}
local exec = function(cmd)
require("kide.term").toggle(cmd)
end
M.setup = function()
vim.api.nvim_create_user_command("Curl", function(opt)
if opt.args == "" then
local ok, url = pcall(vim.fn.input, "URL: ")
if ok then
exec({
"curl",
"-w",
outfmt,
url,
})
end
else
local cmd = {
"curl",
"-w",
outfmt,
}
vim.list_extend(cmd, vim.split(opt.args, " "))
exec(cmd)
end
end, {
nargs = "*",
complete = function()
return { "-vvv", "--no-sessionid" }
end,
})
end
return M