diff options
| author | William Boman <william@redwill.se> | 2023-10-13 17:05:12 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2025-02-19 09:23:19 +0100 |
| commit | 80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa (patch) | |
| tree | 9abe9afe34923fce89d6b9b90a1b41445a4d1cd4 /lua/mason-core/path.lua | |
| parent | feat(path): add relative(from, to) (diff) | |
| download | mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar.gz mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar.bz2 mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar.lz mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar.xz mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.tar.zst mason-80944cbf22e10a4debe59d2f0166fb0cd7b1b1aa.zip | |
feat(linker): use relative targets for symlinks (#1525)
Closes #1156.
Diffstat (limited to 'lua/mason-core/path.lua')
| -rw-r--r-- | lua/mason-core/path.lua | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/lua/mason-core/path.lua b/lua/mason-core/path.lua index 66f0f964..eec3148d 100644 --- a/lua/mason-core/path.lua +++ b/lua/mason-core/path.lua @@ -1,24 +1,9 @@ -local sep = (function() - ---@diagnostic disable-next-line: undefined-global - if jit then - ---@diagnostic disable-next-line: undefined-global - local os = string.lower(jit.os) - if os == "linux" or os == "osx" or os == "bsd" then - return "/" - else - return "\\" - end - else - return string.sub(package.config, 1, 1) - end -end)() - local M = {} ---@param path_components string[] ---@return string function M.concat(path_components) - return table.concat(path_components, sep) + return vim.fs.normalize(table.concat(path_components, "/")) end ---@path root_path string @@ -55,7 +40,7 @@ function M.relative(from, to) local common_parent, distance = find_closest_common_parent(from_normalized, to_normalized) local relative_path_component = distance == 0 and "." or (".."):rep(distance, "/") - return vim.fs.joinpath(relative_path_component, to_normalized:sub(#common_parent + 1)) + return M.concat { relative_path_component, to_normalized:sub(#common_parent + 1) } end return M |
