nvim-sourcer/lua/sourcer/init.lua

23 lines
555 B
Lua

local M = {}
function M.lookup()
local keywords = vim.fn.getreg("*") -- receive yanked text
local url = "https://dl.acm.org/action/doSearch?AllField=" .. keywords
url = url:sub(2, #url)
url, empty = url:gsub(" ", "+")
-- Setup a http socket and request
local command = string.format("curl -s '%s'", url)
-- Execute the curl command and capture its output
local handle = io.popen(command)
local response = handle:read("*a")
handle:close()
print("Keywords: " .. keywords)
print("URL: " .. url)
print("Response: " .. response)
end
return M