mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-04 04:20:09 -04:00
chore!: don't allow to silently use alternative install directory
This commit is contained in:
parent
75e1d88a00
commit
7ab2c037dd
1 changed files with 11 additions and 20 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue