From 5458a86bd38d45d3570d081b740f7a724e29dfb3 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 16 Sep 2024 01:04:46 +0200 Subject: [PATCH] fix: Use $LOCALAPPDATA when loading github token Also use $HOME instead of ~ as its more friendly for expansion on different OS. Fixes #409 Signed-off-by: Tomas Slusny --- lua/CopilotChat/copilot.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lua/CopilotChat/copilot.lua b/lua/CopilotChat/copilot.lua index 61301142..4e6ddfce 100644 --- a/lua/CopilotChat/copilot.lua +++ b/lua/CopilotChat/copilot.lua @@ -79,16 +79,17 @@ local function find_config_path() local config = vim.fn.expand('$XDG_CONFIG_HOME') if config and vim.fn.isdirectory(config) > 0 then return config - elseif vim.fn.has('win32') > 0 then - config = vim.fn.expand('~/AppData/Local') - if vim.fn.isdirectory(config) > 0 then - return config + end + if vim.fn.has('win32') > 0 then + config = vim.fn.expand('$LOCALAPPDATA') + if not config or vim.fn.isdirectory(config) == 0 then + config = vim.fn.expand('$HOME/AppData/Local') end else - config = vim.fn.expand('~/.config') - if vim.fn.isdirectory(config) > 0 then - return config - end + config = vim.fn.expand('$HOME/.config') + end + if config and vim.fn.isdirectory(config) > 0 then + return config end end