Skip to content

Commit 53587fe

Browse files
committed
fix home directory
1 parent a21b58b commit 53587fe

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lua/plenary/path2.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ local S_IF = {
230230
}
231231

232232
---@class plenary.path2
233-
---@field home string home directory path
233+
---@field home string? home directory path
234234
---@field sep string OS path separator respecting 'shellslash'
235235
---@field isshellslash boolean whether shellslash is on (always false on unix systems)
236236
---
@@ -241,7 +241,6 @@ local S_IF = {
241241
---@field root fun(base: string?):string
242242
---@field S_IF { DIR: integer, REG: integer } stat filetype bitmask
243243
local path = setmetatable({
244-
home = vim.fn.getcwd(), -- respects shellslash unlike vim.uv.cwd()
245244
S_IF = S_IF,
246245
}, {
247246
__index = function(t, k)
@@ -262,6 +261,19 @@ local path = setmetatable({
262261

263262
return t.isshellslash and "/" or "\\"
264263
end
264+
265+
if k == "home" then
266+
if not iswin then
267+
t.home = uv.os_homedir()
268+
return t.home
269+
end
270+
271+
local home = uv.os_homedir()
272+
if home == nil then
273+
return home
274+
end
275+
return (home:gsub("\\", t.sep))
276+
end
265277
end,
266278
})
267279

0 commit comments

Comments
 (0)