Skip to content

Commit 90a9092

Browse files
authored
Feat: Implement openURL (zbirenbaum#311)
* Feat: Implement openURL * feat: Use vim.ui.open
1 parent 1a237cf commit 90a9092

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

lua/copilot/api.lua

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,28 @@ mod.handlers = {
227227
PanelSolutionsDone = panel.handlers.PanelSolutionsDone,
228228
statusNotification = status.handlers.statusNotification,
229229
---@param result copilot_open_url_data
230-
["copilot/openURL"] = function(_, result)
231-
vim.api.nvim_echo({
232-
{ "copilot/openURL" },
233-
{ vim.inspect({ _, result }) },
234-
{ "\n", "NONE" },
235-
}, true, {})
236-
error("not implemented: copilot.api.handlers['copilot/openURL']")
237-
end,
230+
["copilot/openURL"] = function(_, result)
231+
local success, _ = pcall(vim.ui.open, result.target)
232+
if not success then
233+
if vim.ui.open ~= nil then
234+
vim.api.nvim_echo({
235+
{ "copilot/openURL" },
236+
{ vim.inspect({ _, result }) },
237+
{ "\n", "NONE" },
238+
}, true, {})
239+
error("Unsupported OS: vim.ui.open exists but failed to execute.")
240+
else
241+
vim.api.nvim_echo({
242+
{ "copilot/openURL" },
243+
{ vim.inspect({ _, result }) },
244+
{ "\n", "NONE" },
245+
}, true, {})
246+
error("Unsupported Version: vim.ui.open requires Neovim > 0.10")
247+
end
248+
end
249+
end
238250
}
251+
239252
mod.panel = panel
240253
mod.status = status
241254

0 commit comments

Comments
 (0)