2024-03-17 14:34:01 +00:00
|
|
|
local string_utils = require("codesnap.utils.string")
|
2024-02-19 14:27:17 +00:00
|
|
|
local path_utils = {}
|
|
|
|
|
|
|
|
function path_utils.back(path)
|
|
|
|
local parsed_path, _ = path:gsub("/[^\\/]+/?$", "")
|
|
|
|
|
|
|
|
return parsed_path
|
|
|
|
end
|
|
|
|
|
2024-03-17 14:34:01 +00:00
|
|
|
function path_utils.get_relative_path()
|
|
|
|
local full_file_path = vim.fn.expand("%:p")
|
|
|
|
local cwd = vim.fn.getcwd()
|
|
|
|
|
|
|
|
return full_file_path:gsub(string_utils.escape(cwd), ""):sub(2)
|
|
|
|
end
|
|
|
|
|
2024-02-19 14:27:17 +00:00
|
|
|
return path_utils
|