open official website for extra of current line

This commit is contained in:
arthur 2024-07-11 02:09:14 +08:00
parent 11268d8ff1
commit 1476f0d277

View file

@ -144,6 +144,9 @@ function X.new()
self.float:on_key("x", function()
self:toggle()
end, "Toggle extra")
self:on_key("o", function()
self:open()
end, "Open extra document")
self.diag = {}
self:update()
return self
@ -156,6 +159,16 @@ function X:diagnostic(diag)
table.insert(self.diag, diag)
end
function X:open()
local pos = vim.api.nvim_win_get_cursor(self.float.win)
for _, extra in ipairs(self.extras) do
if extra.row == pos[1] then
require("lazy.util").open(("https://www.lazyvim.org/%s"):format(extra.name:gsub("%.", "/")))
return
end
end
end
function X:toggle()
local pos = vim.api.nvim_win_get_cursor(self.float.win)
for _, extra in ipairs(self.extras) do