Skip to content

Feat: Implement openURL#311

Merged
zbirenbaum merged 2 commits intozbirenbaum:masterfrom
Al0den:master
Oct 18, 2024
Merged

Feat: Implement openURL#311
zbirenbaum merged 2 commits intozbirenbaum:masterfrom
Al0den:master

Conversation

@Al0den
Copy link
Copy Markdown
Contributor

@Al0den Al0den commented Aug 24, 2024

Fix for #310

Comment thread lua/copilot/api.lua Outdated
{ "\n", "NONE" },
}, true, {})
error("not implemented: copilot.api.handlers['copilot/openURL']")
if package.config:sub(1, 1) == '/' then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use vim.ui.open({path}) instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
No vim.ui.open on
image

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very strange. It's in the docs :h vim.ui.open() and it works for me and im on 0.10.1 as well. You need to run :version from within nvim to check the version.

https://neovim.io/doc/user/lua.html#_lua-module:-vim.ui

@zbirenbaum
Copy link
Copy Markdown
Owner

According to neovim changelogs vim.ui.open has existed since 0.10. Lets use @tmillr suggestion and do something like this:

  ["copilot/openURL"] = function(_, result)
    local success, _ = pcall(vim.ui.open, result.target)
    if not success then
      if vim.ui.open ~= nil then
        vim.api.nvim_echo({
            { "copilot/openURL" },
            { vim.inspect({ _, result }) },
            { "\n", "NONE" },
        }, true, {})
        error("Unsupported OS: vim.ui.open exists but failed to execute.")
      else
        vim.api.nvim_echo({
            { "copilot/openURL" },
            { vim.inspect({ _, result }) },
            { "\n", "NONE" },
        }, true, {})
        error("Unsupported Version: vim.ui.open requires Neovim > 0.10")
      end
    end
  end
}

@Al0den
Copy link
Copy Markdown
Contributor Author

Al0den commented Sep 13, 2024

Super weird, was on 0.10 and didn't have it.
Anyways, changed the commit to include this, thanks!

@zbirenbaum zbirenbaum merged commit 90a9092 into zbirenbaum:master Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants