chore(copilot): check for valid file in addition to plugin setup (#120)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-20 19:00:41 -04:00 committed by GitHub
parent fe30ef6782
commit 76dd441e25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -35,7 +35,7 @@ M.CANCEL_PATTERN = "AvanteLLMEscape"
---@field xcode boolean ---@field xcode boolean
---@field xcode_chat boolean ---@field xcode_chat boolean
--- ---
---@privaate ---@private
---@class AvanteCopilot: table<string, any> ---@class AvanteCopilot: table<string, any>
---@field proxy string ---@field proxy string
---@field allow_insecure boolean ---@field allow_insecure boolean
@ -55,7 +55,7 @@ local E = {
deepseek = "DEEPSEEK_API_KEY", deepseek = "DEEPSEEK_API_KEY",
groq = "GROQ_API_KEY", groq = "GROQ_API_KEY",
copilot = function() copilot = function()
if Utils.has("copilot.lua") or Utils.has("copilot.vim") then if Utils.has("copilot.lua") or Utils.has("copilot.vim") or Utils.copilot.find_config_path() then
return true return true
end end
Utils.warn("copilot is not setup correctly. Please use copilot.lua or copilot.vim for authentication.") Utils.warn("copilot is not setup correctly. Please use copilot.lua or copilot.vim for authentication.")

View File

@ -32,7 +32,7 @@ M.machine_id = function()
end end
---@return string | nil ---@return string | nil
local function find_config_path() M.find_config_path = function()
local config = vim.fn.expand("$XDG_CONFIG_HOME") local config = vim.fn.expand("$XDG_CONFIG_HOME")
if config and vim.fn.isdirectory(config) > 0 then if config and vim.fn.isdirectory(config) > 0 then
return config return config
@ -58,7 +58,7 @@ M.cached_token = function()
end end
-- loading token from the file -- loading token from the file
local config_path = find_config_path() local config_path = M.find_config_path()
if not config_path then if not config_path then
return nil return nil
end end