Skip to content

Commit 4b713b9

Browse files
authored
fix(vsg): don't error if XDG_CONFIG_HOME or HOME are not defined (#839)
On Windows, `XDG_CONFIG_HOME` and `HOME` are not defined by default, which meant that the concatenation turned into `nil .. './config'` resulting in an error. Now `vim.uv.os_homedir()` is used, which should always return a string.
1 parent df83eea commit 4b713b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/conform/formatters/vsg.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ local config_files = {
1414
}
1515

1616
local function find_config(dirname)
17+
local config_dir =
18+
vim.fs.normalize(os.getenv("XDG_CONFIG_HOME") or (vim.uv.os_homedir() .. "/.config"))
19+
1720
local paths = {
1821
dirname,
19-
(os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME") .. "/.config") .. "/vsg",
22+
(config_dir .. "/vsg"),
2023
}
2124

2225
for _, path in ipairs(paths) do

0 commit comments

Comments
 (0)