chore!: don't allow to silently use alternative install directory

This commit is contained in:
Stephan Seitz 2022-08-01 21:40:01 +02:00
parent 75e1d88a00
commit 7ab2c037dd

View file

@ -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.")
)
install_dir = config.parser_install_dir
else
install_dir = utils.get_package_path()
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
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