summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/install.lua
diff options
context:
space:
mode:
authorDuncan McDougall <dncn.mcdougall@gmail.com>2022-06-20 21:50:07 +0100
committerGitHub <noreply@github.com>2022-06-20 22:50:07 +0200
commit901ffe1a363f21c168eacf011dce4f905fd26d5f (patch)
tree49f905970eff9ce1ebefa797798909ea1229cde9 /lua/nvim-treesitter/install.lua
parent37b9a2971f749ab6d5ac9c8792f6e133fed027aa (diff)
Add support for custom parser install locations #2959 (#3031)
Diffstat (limited to 'lua/nvim-treesitter/install.lua')
-rw-r--r--lua/nvim-treesitter/install.lua19
1 files changed, 7 insertions, 12 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index 10f08dac..822e00e6 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -80,7 +80,7 @@ local function get_revision(lang)
end
local function get_installed_revision(lang)
- local lang_file = utils.join_path(utils.get_parser_info_dir(), lang .. ".revision")
+ local lang_file = utils.join_path(configs.get_parser_info_dir(), lang .. ".revision")
if vim.fn.filereadable(lang_file) == 1 then
return vim.fn.readfile(lang_file)[1]
end
@@ -243,9 +243,9 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
compile_location = repo.url
else
local repo_location = string.gsub(repo.location or project_name, "/", path_sep)
- compile_location = cache_folder .. path_sep .. repo_location
+ compile_location = utils.join_path(cache_folder, repo_location)
end
- local parser_lib_name = install_folder .. path_sep .. lang .. ".so"
+ local parser_lib_name = utils.join_path(install_folder, lang) .. ".so"
generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar
@@ -329,7 +329,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
shell.select_mv_cmd("parser.so", parser_lib_name, compile_location),
{
cmd = function()
- vim.fn.writefile({ revision or "" }, utils.join_path(utils.get_parser_info_dir(), lang .. ".revision"))
+ vim.fn.writefile({ revision or "" }, utils.join_path(configs.get_parser_info_dir(), lang .. ".revision"))
end,
},
{ -- auto-attach modules after installation
@@ -392,7 +392,7 @@ local function install(options)
return api.nvim_err_writeln(err)
end
- local install_folder, err = utils.get_parser_install_dir()
+ local install_folder, err = configs.get_parser_install_dir()
if err then
return api.nvim_err_writeln(err)
end
@@ -459,11 +459,6 @@ function M.update(options)
end
function M.uninstall(...)
- local path_sep = "/"
- if fn.has "win32" == 1 then
- path_sep = "\\"
- end
-
if vim.tbl_contains({ "all" }, ...) then
reset_progress_counter()
local installed = info.installed_parsers()
@@ -473,12 +468,12 @@ function M.uninstall(...)
elseif ... then
local languages = vim.tbl_flatten { ... }
for _, lang in ipairs(languages) do
- local install_dir, err = utils.get_parser_install_dir()
+ local install_dir, err = configs.get_parser_install_dir()
if err then
return api.nvim_err_writeln(err)
end
- local parser_lib = install_dir .. path_sep .. lang .. ".so"
+ local parser_lib = utils.join_path(install_dir, lang) .. ".so"
local command_list = {
shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang),