File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,23 @@ use { "zbirenbaum/copilot.lua" }
2222
2323### Authentication
2424
25+ You can authenticate using one of the following methods:
26+
27+ #### Permanent sign-in (Recommended)
28+
2529Once copilot is running, run ` :Copilot auth ` to start the authentication process.
2630
31+ #### Token
32+
33+ Get a token from the github cli using:
34+
35+ ``` sh
36+ gh auth token
37+ ```
38+
39+ Set either the environment variable ` GITHUB_COPILOT_TOKEN ` or ` GH_COPILOT_TOKEN ` to that token.
40+ Note that if you have the variable set, even empty, the LSP will attempt to use it to log in.
41+
2742## Setup and Configuration
2843
2944You have to run the ` require("copilot").setup(options) ` function in order to start Copilot.
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ local config = require("copilot.config")
33local highlight = require (" copilot.highlight" )
44local logger = require (" copilot.logger" )
55local client = require (" copilot.client" )
6+ local auth = require (" copilot.auth" )
67
78local create_cmds = function ()
89 vim .api .nvim_create_user_command (" CopilotDetach" , function ()
@@ -47,6 +48,12 @@ M.setup = function(opts)
4748 -- logged here to ensure the logger is setup
4849 logger .debug (" active LSP config (may change runtime):" , client .config )
4950
51+ local token_env_set = (os.getenv (" GITHUB_COPILOT_TOKEN" ) ~= nil ) or (os.getenv (" GH_COPILOT_TOKEN" ) ~= nil )
52+
53+ if token_env_set then
54+ auth .signin ()
55+ end
56+
5057 M .setup_done = true
5158end
5259
You can’t perform that action at this time.
0 commit comments