mirror of https://github.com/ray-x/go.nvim
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
587 B
Lua
25 lines
587 B
Lua
2 years ago
|
local utils = require("go.utils")
|
||
|
local log = utils.log
|
||
|
local curl = "curl"
|
||
|
local run = function(...)
|
||
|
local query = select(1, ...)
|
||
|
local cmd = string.format('%s cht.sh/go/%s?T', curl, query)
|
||
|
|
||
|
local data = vim.fn.systemlist(cmd, vim.fn.bufnr('%'))
|
||
|
|
||
|
data = utils.handle_job_data(data)
|
||
|
if not data then
|
||
|
return
|
||
|
end
|
||
|
-- log(data)
|
||
|
if #data > 0 then
|
||
|
data = vim.list_slice(data, 4, #data)
|
||
|
local name = vim.fn.tempname() .. ".go"
|
||
|
vim.fn.writefile(data, name)
|
||
|
cmd = " silent exe 'e " .. name .. "'"
|
||
|
vim.cmd(cmd)
|
||
|
vim.cmd('e')
|
||
|
end
|
||
|
end
|
||
|
return {run = run}
|