23 lines
476 B
Lua
23 lines
476 B
Lua
-- https://github.com/folke/lazy.nvim/blob/main/lua/lazy/core/util.lua
|
|
|
|
---@class lib.lazy.util
|
|
local M = {}
|
|
|
|
---@return string
|
|
function M.norm(path)
|
|
if path:sub(1, 1) == '~' then
|
|
local home = vim.uv.os_homedir() or ''
|
|
|
|
if home:sub(-1) == '\\' or home:sub(-1) == '/' then
|
|
home = home:sub(1, -2)
|
|
end
|
|
|
|
path = home .. path:sub(2)
|
|
end
|
|
|
|
path = path:gsub('\\', '/'):gsub('/+', '/')
|
|
|
|
return path:sub(-1) == '/' and path:sub(1, -2) or path
|
|
end
|
|
|
|
return M
|