From 2ace3d37265839e543a2eb48057b98fd8a12e5e9 Mon Sep 17 00:00:00 2001 From: yannickreiss Date: Sun, 18 Feb 2024 12:39:40 +0100 Subject: [PATCH] Request contents from ACM --- lua/sourcer/init.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lua/sourcer/init.lua b/lua/sourcer/init.lua index dcc51ba..1e162ac 100644 --- a/lua/sourcer/init.lua +++ b/lua/sourcer/init.lua @@ -1,9 +1,18 @@ local M = {} function M.lookup() - local keywords = vim.fn.getreg("*") + local keywords = vim.fn.getreg("") -- receive highlighted text + local url = "https://dl.acm.org/action/doSearch?AllField=" .. keywords - print(keywords) + -- Setup a http socket and request + local http = require("socket.http") + local response, status_code, headers = http.request(url) + + if status_code == 200 then + print(response) + else + print("Getting sources failed with error code " .. status_code .. "!") + end end return M