From 7ab2c037dd31afe4112a7ac22463bc8410f42219 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 1 Aug 2022 21:40:01 +0200 Subject: chore!: don't allow to silently use alternative install directory --- lua/nvim-treesitter/configs.lua | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index e0618c86..ee34c942 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -1,5 +1,4 @@ local api = vim.api -local luv = vim.loop local queries = require "nvim-treesitter.query" local ts_query = require "vim.treesitter.query" @@ -548,30 +547,22 @@ end function M.get_parser_install_dir(folder_name) folder_name = folder_name or "parser" + local install_dir if config.parser_install_dir then - local parser_dir = utils.join_path(config.parser_install_dir, folder_name) - return utils.create_or_reuse_writable_dir( - parser_dir, - utils.join_space("Could not create parser dir '", parser_dir, "': "), - utils.join_space("Parser dir '", parser_dir, "' should be read/write.") - ) - end - - local package_path = utils.get_package_path() - local package_path_parser_dir = utils.join_path(package_path, folder_name) - - -- If package_path is read/write, use that - if luv.fs_access(package_path_parser_dir, "RW") then - return package_path_parser_dir + install_dir = config.parser_install_dir + else + install_dir = utils.get_package_path() end - - local site_dir = utils.get_site_dir() - local parser_dir = utils.join_path(site_dir, folder_name) + local parser_dir = utils.join_path(install_dir, folder_name) return utils.create_or_reuse_writable_dir( parser_dir, - nil, - utils.join_space("Invalid rights,", package_path, "or", parser_dir, "should be read/write") + utils.join_space("Could not create parser dir '", parser_dir, "': "), + utils.join_space( + "Parser dir '", + parser_dir, + "' should be read/write (see README on how to configure an alternative install location)" + ) ) end -- cgit v1.2.3