Something went wrong. Try again.
Just a preview for Neovim's quickfix list
Something went wrong. Try again.
584 B · 31 lines
Lua
at master
1234567891011121314151617181920212223242526272829303132local M = {}
---@param path string---@param cwd string---@return stringfunction M.normalize_path(path, cwd) if path == cwd then return "." end
-- if `path` is a subpath of `cwd`, remove `cwd` to make it relative if path:sub(1, #cwd) == cwd then return path:sub(#cwd + 2) end
-- if `path` is under the home directory, return it with `~` local home = os.getenv("HOME") if home then if path == home then return "~" end
if path:sub(1, #home) == home then return "~/" .. path:sub(#home + 2) end end
return pathend
return M