CopilotC-Nvim / CopilotChat.nvim

Chat with GitHub Copilot in Neovim
https://copilotc-nvim.github.io/CopilotChat.nvim/
GNU General Public License v3.0
1.65k stars 73 forks source link

Allow reading GITHUB_TOKEN from environment #275

Closed lingjie00 closed 6 months ago

lingjie00 commented 6 months ago

Good day! When I was trying to run this plugin in GitHub Codespace, I realised github/copilot.vim plug-in works but CopilotChat.nvim is unable to find hosts.json.

After some digging, I realised this might be due to copilot.vim loading token from environment GITHUB_TOKEN and not creating /github-copilot/hosts.json as expected.

Recommended fix would be to modify get_cached_token() function in copilot.lua

local function get_cached_token()
-- get oauth token from environment variable
    local token = os.getenv('GITHUB_TOKEN')
    if token then
        return token
    end

-- continue with existing function
lingjie00 commented 6 months ago

Created PR https://github.com/CopilotC-Nvim/CopilotChat.nvim/pull/276