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" }
22
22
23
23
### Authentication
24
24
25
+ You can authenticate using one of the following methods:
26
+
27
+ #### Permanent sign-in (Recommended)
28
+
25
29
Once copilot is running, run ` :Copilot auth ` to start the authentication process.
26
30
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
+
27
42
## Setup and Configuration
28
43
29
44
You 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")
3
3
local highlight = require (" copilot.highlight" )
4
4
local logger = require (" copilot.logger" )
5
5
local client = require (" copilot.client" )
6
+ local auth = require (" copilot.auth" )
6
7
7
8
local create_cmds = function ()
8
9
vim .api .nvim_create_user_command (" CopilotDetach" , function ()
@@ -47,6 +48,12 @@ M.setup = function(opts)
47
48
-- logged here to ensure the logger is setup
48
49
logger .debug (" active LSP config (may change runtime):" , client .config )
49
50
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
+
50
57
M .setup_done = true
51
58
end
52
59
You can’t perform that action at this time.
0 commit comments