From b66b533ecdf40524176020cff514c0597c99df0b Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 28 Sep 2020 17:29:48 +0200 Subject: chore: dedup join_paths <-> join_path --- lua/nvim-treesitter/install.lua | 6 +++--- lua/nvim-treesitter/utils.lua | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 61612f458..ebb0b14fc 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -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) diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index 93c2a8d6d..17e7ff95e 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -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 -- cgit v1.2.3-70-g09d2