Skip to content

Commit b20f595

Browse files
committed
find_config_path fix and error message on fail
1 parent 7e0c03d commit b20f595

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lua/copilot/setup.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ local M = {}
22

33
local function find_config_path()
44
local config = vim.fn.expand('$XDG_CONFIG_HOME')
5-
if config and config ~= '' then return config end
6-
config = vim.fn.has('win32') and vim.fn.expand('~/AppData/Local') or nil
7-
return config or vim.fn.expand('~/.config')
5+
if config and vim.fn.isdirectory(config) > 0 then
6+
return config
7+
elseif vim.fn.has('win32') > 0 then
8+
config = vim.fn.expand('~/AppData/Local')
9+
if vim.fn.isdirectory(config) > 0 then return config end
10+
else
11+
config = vim.fn.expand('~/.config')
12+
if vim.fn.isdirectory(config) > 0 then return config
13+
else print("Error: could not find config path")
14+
end
15+
end
816
end
917

1018

0 commit comments

Comments
 (0)