diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index bd38bc1..7f99819 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -85,7 +85,7 @@ Your task is to modify the provided code according to the user's request. Follow 8. Only return the new code snippets to be updated, DO NOT return the entire file content. -Remember: Your response should contain nothing but ONLY the modified code, ready to be used as a direct replacement for the original file. +Remember: Your response should contain ONLY the modified code, ready to be used as a direct replacement for the original file. ]] local group = api.nvim_create_augroup("avante_llm", { clear = true }) diff --git a/lua/avante/providers/copilot.lua b/lua/avante/providers/copilot.lua index bb20008..b10b265 100644 --- a/lua/avante/providers/copilot.lua +++ b/lua/avante/providers/copilot.lua @@ -52,10 +52,20 @@ H.get_oauth_token = function() config_dir = vim.fn.expand("~/AppData/Local") end - local yason = Path:new(config_dir):joinpath("github-copilot", "hosts.json") - if not yason:exists() then + --- hosts.json (copilot.lua), apps.json (copilot.vim) + ---@type Path[] + local paths = vim.iter({ "hosts.json", "apps.json" }):fold({}, function(acc, path) + local yason = Path:new(config_dir):joinpath("github-copilot", path) + if yason:exists() then + table.insert(acc, yason) + end + return acc + end) + if #paths == 0 then error("You must setup copilot with either copilot.lua or copilot.vim", 2) end + + local yason = paths[1] return vim .iter( ---@type table @@ -119,16 +129,12 @@ M.state = nil M.api_key_name = P.AVANTE_INTERNAL_KEY M.parse_message = function(opts) - local user_prompt = "" - for _, user_prompt_ in ipairs(opts.user_prompts) do - user_prompt = user_prompt .. "\n\n" .. user_prompt_ - end - return { { role = "system", content = opts.system_prompt }, - { role = "user", content = user_prompt }, + { role = "user", content = table.concat(opts.user_prompts, "\n\n") }, } end + M.parse_response = O.parse_response M.parse_curl_args = function(provider, code_opts)