From 76dd441e2583db4ba7e42e6572229a77b9dd40a1 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Tue, 20 Aug 2024 19:00:41 -0400 Subject: [PATCH] chore(copilot): check for valid file in addition to plugin setup (#120) Signed-off-by: Aaron Pham --- lua/avante/llm.lua | 4 ++-- lua/avante/utils/copilot.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index 62d0805..4a4c593 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -35,7 +35,7 @@ M.CANCEL_PATTERN = "AvanteLLMEscape" ---@field xcode boolean ---@field xcode_chat boolean --- ----@privaate +---@private ---@class AvanteCopilot: table ---@field proxy string ---@field allow_insecure boolean @@ -55,7 +55,7 @@ local E = { deepseek = "DEEPSEEK_API_KEY", groq = "GROQ_API_KEY", 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 end Utils.warn("copilot is not setup correctly. Please use copilot.lua or copilot.vim for authentication.") diff --git a/lua/avante/utils/copilot.lua b/lua/avante/utils/copilot.lua index 2c33e70..3dd1c79 100644 --- a/lua/avante/utils/copilot.lua +++ b/lua/avante/utils/copilot.lua @@ -32,7 +32,7 @@ M.machine_id = function() end ---@return string | nil -local function find_config_path() +M.find_config_path = function() local config = vim.fn.expand("$XDG_CONFIG_HOME") if config and vim.fn.isdirectory(config) > 0 then return config @@ -58,7 +58,7 @@ M.cached_token = function() end -- loading token from the file - local config_path = find_config_path() + local config_path = M.find_config_path() if not config_path then return nil end