From 7cd63a597efd7b86456e78e8a6d5355825f40611 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 13 Oct 2023 08:54:03 +0200 Subject: [PATCH] Copilot: Add more search paths for agent.js Fixes: QTCREATORBUG-29750 Change-Id: I19c5ad41705daf00ae08fec88bd9ed40b8a34d12 Reviewed-by: David Schulz --- src/plugins/copilot/copilotsettings.cpp | 30 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/plugins/copilot/copilotsettings.cpp b/src/plugins/copilot/copilotsettings.cpp index 38683d9acdf..24e83618788 100644 --- a/src/plugins/copilot/copilotsettings.cpp +++ b/src/plugins/copilot/copilotsettings.cpp @@ -43,15 +43,27 @@ CopilotSettings::CopilotSettings() const FilePath nodeFromPath = FilePath("node").searchInPath(); - const FilePaths searchDirs - = {FilePath::fromUserInput("~/.vim/pack/github/start/copilot.vim/dist/agent.js"), - FilePath::fromUserInput("~/.vim/pack/github/start/copilot.vim/copilot/dist/agent.js"), - FilePath::fromUserInput( - "~/.config/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js"), - FilePath::fromUserInput( - "~/vimfiles/pack/github/start/copilot.vim/copilot/dist/agent.js"), - FilePath::fromUserInput( - "~/AppData/Local/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js")}; + // clang-format off + + // From: https://github.com/github/copilot.vim/blob/release/README.md#getting-started + const FilePaths searchDirs = { + // Vim, Linux/macOS: + FilePath::fromUserInput("~/.vim/pack/github/start/copilot.vim/dist/agent.js"), + FilePath::fromUserInput("~/.vim/pack/github/start/copilot.vim/copilot/dist/agent.js"), + + // Neovim, Linux/macOS: + FilePath::fromUserInput("~/.config/nvim/pack/github/start/copilot.vim/dist/agent.js"), + FilePath::fromUserInput("~/.config/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js"), + + // Vim, Windows (PowerShell command): + FilePath::fromUserInput("~/vimfiles/pack/github/start/copilot.vim/dist/agent.js"), + FilePath::fromUserInput("~/vimfiles/pack/github/start/copilot.vim/copilot/dist/agent.js"), + + // Neovim, Windows (PowerShell command): + FilePath::fromUserInput("~/AppData/Local/nvim/pack/github/start/copilot.vim/dist/agent.js"), + FilePath::fromUserInput("~/AppData/Local/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js") + }; + // clang-format on const FilePath distFromVim = findOrDefault(searchDirs, &FilePath::exists);