@@ -908,18 +908,43 @@ function m.countStates()
908
908
return n
909
909
end
910
910
911
+ --- Resolve path variables/placeholders like ${3rd} and ${addons}
911
912
--- @param path string
912
- --- @return string
913
- function m .normalize (path )
914
- path = path :gsub (' %$%{(.-)%}' , function (key )
915
- if key == ' 3rd' then
916
- return (ROOT / ' meta' / ' 3rd' ):string ()
917
- end
918
- if key :sub (1 , 4 ) == ' env:' then
913
+ --- @return string resolvedPath
914
+ function m .resolvePathPlaceholders (path )
915
+ path = path :gsub (" %$%{(.-)%}" , function (key )
916
+ if key == " 3rd" then
917
+ return (ROOT / " meta" / " 3rd" ):string ()
918
+ elseif key == " addons" then
919
+ -- Common path across OSes
920
+ local dataPath = " User/globalStorage/sumneko.lua/addonManager/addons"
921
+
922
+ if platform .os == " windows" then
923
+ return " $APPDATA/Code/" .. dataPath
924
+ elseif platform .os == " linux" then
925
+ local serverPath = util .expandPath (fs .path (" ~/.vscode-server/data" ):string ())
926
+ if fs .exists (serverPath ) then
927
+ -- addons are installed via SSH remote
928
+ return serverPath .. " /" .. dataPath
929
+ else
930
+ return " ~/.config/Code/" .. dataPath
931
+ end
932
+ elseif platform .os == " macos" then
933
+ return " ~/Library/Application/Support/Code/" .. dataPath
934
+ end
935
+ elseif key :sub (1 , 4 ) == " env:" then
919
936
local env = os.getenv (key :sub (5 ))
920
937
return env
921
938
end
922
939
end )
940
+
941
+ return path
942
+ end
943
+
944
+ --- @param path string
945
+ --- @return string
946
+ function m .normalize (path )
947
+ path = m .resolvePathPlaceholders (path )
923
948
path = util .expandPath (path )
924
949
path = path :gsub (' ^%.[/\\ ]+' , ' ' )
925
950
for _ = 1 , 1000 do
0 commit comments