-
Notifications
You must be signed in to change notification settings - Fork 134
Expose is_authenticated()
helper
#519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c1c2ffa
graceful handling for unauthenticated users with is_unauthenticated()
7d014f4
move is_authenticated to look at LSP server and add health check module
3d0d7a4
fix auth test
1a31f1b
added wait_for_lsp_authentication() test helper to fix suggestion tests
b7af690
Merge branch 'master' into master
AntoineGS 87ed23a
Revert "added wait_for_lsp_authentication() test helper to fix sugges…
AntoineGS 8668e85
prevent having to request a second suggestion after the auth request …
AntoineGS d542347
Merge branch 'master' into master
AntoineGS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
local M = {} | ||
|
||
local api = require("copilot.api") | ||
local auth = require("copilot.auth") | ||
local c = require("copilot.client") | ||
local config = require("copilot.config") | ||
|
||
local start = vim.health.start or vim.health.report_start | ||
local ok = vim.health.ok or vim.health.report_ok | ||
local warn = vim.health.warn or vim.health.report_warn | ||
local error = vim.health.error or vim.health.report_error | ||
local info = vim.health.info or vim.health.report_info | ||
|
||
function M.check() | ||
start("{copilot.lua}") | ||
info("{copilot.lua} GitHub Copilot plugin for Neovim") | ||
|
||
start("Copilot Dependencies") | ||
|
||
if vim.fn.executable("node") == 1 then | ||
local node_version = vim.fn.system("node --version"):gsub("\n", "") | ||
ok("`node` found: " .. node_version) | ||
else | ||
error("`node` not found in PATH") | ||
info("Install Node.js from https://nodejs.org") | ||
end | ||
|
||
start("Copilot Authentication") | ||
|
||
local github_token = os.getenv("GITHUB_COPILOT_TOKEN") | ||
local gh_token = os.getenv("GH_COPILOT_TOKEN") | ||
if github_token or gh_token then | ||
ok("Environment token found: " .. (github_token and "`GITHUB_COPILOT_TOKEN`" or "`GH_COPILOT_TOKEN`")) | ||
else | ||
info("No environment token set (`GITHUB_COPILOT_TOKEN` or `GH_COPILOT_TOKEN`)") | ||
end | ||
|
||
local config_path = auth.find_config_path() | ||
local creds_ok, creds = pcall(auth.get_creds) | ||
if creds_ok and creds then | ||
ok("Local credentials file found") | ||
info("Location: `" .. (config_path or "unknown") .. "/github-copilot/apps.json`") | ||
else | ||
info("No local credentials file found") | ||
info("Expected location: `" .. (config_path or "unknown") .. "/github-copilot/apps.json`") | ||
info("Run `:Copilot auth` to authenticate") | ||
end | ||
|
||
local client = c.get() | ||
if not client then | ||
error("Copilot LSP client not available") | ||
info("Check that the plugin is properly loaded and configured") | ||
info("Or restart Neovim if the plugin was just installed") | ||
return | ||
end | ||
|
||
start("Copilot LSP Status") | ||
ok("LSP client is available and running") | ||
info("Client ID: " .. tostring(client.id)) | ||
|
||
local lsp_authenticated = auth.is_authenticated() | ||
if lsp_authenticated then | ||
ok("LSP authentication status: authenticated") | ||
else | ||
warn("LSP authentication status: not authenticated") | ||
end | ||
info("For detailed authentication status, run `:Copilot status`") | ||
|
||
start("Copilot Configuration") | ||
local suggestion_config = config.suggestion | ||
if suggestion_config and suggestion_config.enabled ~= false then | ||
ok("Suggestions enabled") | ||
if suggestion_config.auto_trigger ~= false then | ||
info("Auto-trigger: enabled") | ||
else | ||
info("Auto-trigger: disabled (manual trigger only)") | ||
end | ||
else | ||
warn("Suggestions disabled in configuration") | ||
info("Enable with `suggestion = { enabled = true }` in setup()") | ||
end | ||
|
||
local panel_config = config.panel | ||
if panel_config and panel_config.enabled ~= false then | ||
ok("Panel enabled") | ||
info("Panel Keybinding: " .. (panel_config.keymap and panel_config.keymap.open or "<M-CR>")) | ||
else | ||
info("Panel disabled in configuration") | ||
info("Enable with `panel = { enabled = true }` in setup()") | ||
end | ||
end | ||
|
||
return M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a screenshot of what this current healthcheck setup looks like:
