diff options
author | dundargoc <gocdundar@gmail.com> | 2024-12-30 16:01:00 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2025-01-13 13:14:52 +0100 |
commit | 0631492f9c8044a378dc2a17ea257badfbda6d15 (patch) | |
tree | 9fca9c84d79c76df83e0689122874e4f1ff262f9 /test/testutil.lua | |
parent | a3ef29d570dd892a1bcbfa80bb242d4aac89a06e (diff) | |
download | rneovim-0631492f9c8044a378dc2a17ea257badfbda6d15.tar.gz rneovim-0631492f9c8044a378dc2a17ea257badfbda6d15.tar.bz2 rneovim-0631492f9c8044a378dc2a17ea257badfbda6d15.zip |
feat: add vim.fs.relpath
This is needed to replace the nvim-lspconfig function is_descendant that
some lspconfg configurations still use.
Diffstat (limited to 'test/testutil.lua')
-rw-r--r-- | test/testutil.lua | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/test/testutil.lua b/test/testutil.lua index 007e017ac6..3226bfeb1e 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -22,13 +22,6 @@ local M = { paths = Paths, } ---- @param p string ---- @return string -local function relpath(p) - p = vim.fs.normalize(p) - return (p:gsub('^' .. uv.cwd, '')) -end - --- @param path string --- @return boolean function M.isdir(path) @@ -45,14 +38,15 @@ end --- (Only on Windows) Replaces yucky "\\" slashes with delicious "/" slashes in a string, or all --- string values in a table (recursively). --- ---- @param obj string|table ---- @return any +--- @generic T: string|table +--- @param obj T +--- @return T|nil function M.fix_slashes(obj) if not M.is_os('win') then return obj end if type(obj) == 'string' then - local ret = obj:gsub('\\', '/') + local ret = string.gsub(obj, '\\', '/') return ret elseif type(obj) == 'table' then --- @cast obj table<any,any> @@ -482,7 +476,8 @@ function M.check_cores(app, force) -- luacheck: ignore -- "./Xtest-tmpdir/" => "Xtest%-tmpdir" local local_tmpdir = nil if tmpdir_is_local and tmpdir then - local_tmpdir = vim.pesc(relpath(tmpdir):gsub('^[ ./]+', ''):gsub('%/+$', '')) + local_tmpdir = + vim.pesc(vim.fs.relpath(assert(vim.uv.cwd()), tmpdir):gsub('^[ ./]+', ''):gsub('%/+$', '')) end local db_cmd --- @type string |