Replaced print statements by write statements for nvim floating window
This commit is contained in:
parent
0e7348af80
commit
2e6580d6b4
|
@ -54,7 +54,16 @@ function M.lookup()
|
||||||
url, empty = url:gsub(" ", "+")
|
url, empty = url:gsub(" ", "+")
|
||||||
open_window()
|
open_window()
|
||||||
|
|
||||||
print("Starting the request")
|
-- enable write to buffer
|
||||||
|
api.nvim_buf_set_option(buf, "modifiable", true)
|
||||||
|
|
||||||
|
api.nvim_buf_set_lines(buf, 0, 1, false, {
|
||||||
|
"Interesting ACM Publications",
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_buf_set_lines(buf, 1, 2, false, {
|
||||||
|
"Requesting papers from ACM...",
|
||||||
|
})
|
||||||
|
|
||||||
-- Setup a http socket and request
|
-- Setup a http socket and request
|
||||||
local command = string.format("wget -q -O - '%s'", url)
|
local command = string.format("wget -q -O - '%s'", url)
|
||||||
|
@ -72,16 +81,21 @@ function M.lookup()
|
||||||
-- extract the rss feed link
|
-- extract the rss feed link
|
||||||
local rss_url = response:match('"https://dl%.acm%.org/action/showFeed%?.-"')
|
local rss_url = response:match('"https://dl%.acm%.org/action/showFeed%?.-"')
|
||||||
if rss_url == nil then
|
if rss_url == nil then
|
||||||
print("ERROR in URL")
|
api.nvim_buf_set_lines(buf, 3, 4, false, {
|
||||||
|
"ERROR: Could not locate Feed!",
|
||||||
|
})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
rss_url = rss_url:sub(2, #rss_url - 1)
|
rss_url = rss_url:sub(2, #rss_url - 1)
|
||||||
|
|
||||||
print("Feed found at: " .. rss_url)
|
api.nvim_buf_set_lines(buf, 3, 4, false, {
|
||||||
|
"Feed found at: " .. rss_url,
|
||||||
|
})
|
||||||
|
|
||||||
local rss_content = httprequest(rss_url)
|
local rss_content = httprequest(rss_url)
|
||||||
print("Received feed content")
|
api.nvim_buf_set_lines(buf, 4, 5, false, {
|
||||||
print(rss_content)
|
"Received feed content",
|
||||||
|
})
|
||||||
|
|
||||||
-- skip initial block
|
-- skip initial block
|
||||||
local b, b_start = rss_content:find("</image>", 1, false)
|
local b, b_start = rss_content:find("</image>", 1, false)
|
||||||
|
@ -150,12 +164,22 @@ function M.lookup()
|
||||||
b = y
|
b = y
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Keywords: " .. keywords)
|
local current_line = 2
|
||||||
print("URL: " .. url)
|
for x = 1, #dates do
|
||||||
print("Title: " .. #titles)
|
api.nvim_buf_set_lines(buf, current_line, -1, false, titles[x])
|
||||||
print("Links: " .. #links)
|
current_line = current_line + 1
|
||||||
print("Descriptions: " .. #descriptions)
|
api.nvim_buf_set_lines(buf, current_line, -1, false, dates[x])
|
||||||
print("Dates: " .. #dates)
|
current_line = current_line + 1
|
||||||
|
api.nvim_buf_set_lines(buf, current_line, -1, false, descriptions[x])
|
||||||
|
current_line = current_line + 1
|
||||||
|
api.nvim_buf_set_lines(buf, current_line, -1, false, links[x])
|
||||||
|
current_line = current_line + 1
|
||||||
|
api.nvim_buf_set_lines(buf, current_line, -1, false, "---")
|
||||||
|
current_line = current_line + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- disable write / make buffer readonly
|
||||||
|
api.nvim_buf_set_option(buf, "modifiable", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue