chore: dedup join_paths <-> join_path

This commit is contained in:
Stephan Seitz
2020-09-28 17:29:48 +02:00
committed by Stephan Seitz
parent 0e37148dd1
commit b66b533ecd
2 changed files with 7 additions and 12 deletions

View File

@@ -32,7 +32,7 @@ end
local function get_revision(lang)
if #lockfile == 0 then
lockfile = vim.fn.json_decode(vim.fn.readfile(utils.join_paths(utils.get_package_path(), 'lockfile.json')))
lockfile = vim.fn.json_decode(vim.fn.readfile(utils.join_path(utils.get_package_path(), 'lockfile.json')))
end
return (lockfile[lang] and lockfile[lang].revision)
end
@@ -217,7 +217,7 @@ local function select_download_commands(repo, project_name, cache_folder, revisi
},
},
select_rm_file_cmd(cache_folder..path_sep..project_name..".zip"),
select_mv_cmd(utils.join_paths(project_name..'-tmp', repo.url:match('[^/]-$')..'-'..revision),
select_mv_cmd(utils.join_path(project_name..'-tmp', repo.url:match('[^/]-$')..'-'..revision),
project_name,
cache_folder),
select_install_rm_cmd(cache_folder, project_name..'-tmp')
@@ -403,7 +403,7 @@ function M.write_lockfile(verbose)
print(vim.inspect(lockfile))
end
vim.fn.writefile(vim.fn.split(vim.fn.json_encode(lockfile), '\n'),
utils.join_paths(utils.get_package_path(), "lockfile.json"))
utils.join_path(utils.get_package_path(), "lockfile.json"))
end
M.ensure_installed = install(false, false)

View File

@@ -21,11 +21,6 @@ function M.get_path_sep()
return fn.has('win32') == 1 and '\\' or '/'
end
function M.join_paths(...)
local sep = M.get_path_sep()
return table.concat({...}, sep)
end
-- Returns a function that joins the given arguments with separator. Arguments
-- can't be nil. Example:
--[[
@@ -38,7 +33,7 @@ function M.generate_join(separator)
end
end
local join_path = M.generate_join(M.get_path_sep())
M.join_path = M.generate_join(M.get_path_sep())
local join_space = M.generate_join(" ")
@@ -66,7 +61,7 @@ end
-- runtimepath
function M.get_site_dir()
local path_sep = M.get_path_sep()
return join_path(fn.stdpath('data'), path_sep, 'site')
return M.join_path(fn.stdpath('data'), path_sep, 'site')
end
-- Try the package dir of the nvim-treesitter plugin first, followed by the
@@ -75,7 +70,7 @@ end
-- with Nix, since the "/nix/store" is read-only.
function M.get_parser_install_dir()
local package_path = M.get_package_path()
local package_path_parser_dir = join_path(package_path, "parser")
local package_path_parser_dir = M.join_path(package_path, "parser")
-- If package_path is read/write, use that
if luv.fs_access(package_path_parser_dir, 'RW') then
@@ -84,7 +79,7 @@ function M.get_parser_install_dir()
local site_dir = M.get_site_dir()
local path_sep = M.get_path_sep()
local parser_dir = join_path(site_dir, path_sep, 'parser')
local parser_dir = M.join_path(site_dir, path_sep, 'parser')
-- Try creating and using parser_dir if it doesn't exist
if not luv.fs_stat(parser_dir) then