Skip to content

Commit

Permalink
Add storagePath handling and memoization to resolvePathPlaceholders
Browse files Browse the repository at this point in the history
  • Loading branch information
sparr committed Oct 8, 2024
1 parent f6dcbcc commit 4b6540d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Fixed an issue preventing to set the locale to Japanese
* `FIX` Accept storagePath option from client to resolve addon directory not found

## 3.11.0
* `NEW` Added support for Japanese locale
Expand Down
40 changes: 26 additions & 14 deletions script/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ function m.countStates()
return n
end

local addonsPath

---Resolve path variables/placeholders like ${3rd} and ${addons}
---@param path string
---@return string resolvedPath
Expand All @@ -914,22 +916,32 @@ function m.resolvePathPlaceholders(path)
if key == "3rd" then
return (ROOT / "meta" / "3rd"):string()
elseif key == "addons" then
-- Common path across OSes
local dataPath = "User/globalStorage/sumneko.lua/addonManager/addons"

if platform.os == "windows" then
return "$APPDATA/Code/" .. dataPath
elseif platform.os == "linux" then
local serverPath = util.expandPath(fs.path("~/.vscode-server/data"):string())
if fs.exists(serverPath) then
-- addons are installed via SSH remote
return serverPath .."/" .. dataPath
else
return "~/.config/Code/" .. dataPath
if addonsPath then
return addonsPath
end
local client = require 'client'
local storagePath = client.getOption('storagePath')
if storagePath then
addonsPath = storagePath .. "/addonManager/addons"
else
-- Common path across OSes
local dataPath = "User/globalStorage/sumneko.lua/addonManager/addons"

if platform.os == "windows" then
addonsPath = "$APPDATA/Code/" .. dataPath
elseif platform.os == "linux" then
local serverPath = util.expandPath(fs.path("~/.vscode-server/data"):string())
if fs.exists(serverPath) then
-- addons are installed via SSH remote
addonsPath = serverPath .."/" .. dataPath
else
addonsPath = "~/.config/Code/" .. dataPath
end
elseif platform.os == "macos" then
addonsPath = "~/Library/Application Support/Code/" .. dataPath
end
elseif platform.os == "macos" then
return "~/Library/Application Support/Code/" .. dataPath
end
return addonsPath
elseif key:sub(1, 4) == "env:" then
local env = os.getenv(key:sub(5))
return env
Expand Down

0 comments on commit 4b6540d

Please sign in to comment.