From 11a8812a477969e913913b51550e14cdb4bfcb8c Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 1 Aug 2022 21:58:01 +0200 Subject: fix: add hint when there parser is still installed after TSUninstall --- lua/nvim-treesitter/install.lua | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'lua/nvim-treesitter') diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 648b5552..8e2e8146 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -490,11 +490,36 @@ function M.uninstall(...) end local parser_lib = utils.join_path(install_dir, lang) .. ".so" - - local command_list = { - shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang), - } - M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") + local all_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) + if vim.fn.filereadable(parser_lib) == 1 then + local command_list = { + shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang), + { + cmd = function() + local all_parsers_after_deletion = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) + if #all_parsers_after_deletion > 0 then + vim.notify( + "Tried to uninstall parser for " + .. lang + .. "! But the parser is still installed (not by nvim-treesitter)." + .. " Please delete the following files manually: " + .. table.concat(all_parsers_after_deletion, ", "), + vim.log.levels.ERROR + ) + end + end, + }, + } + M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") + elseif #all_parsers > 0 then + vim.notify( + "Parser for " + .. lang + .. " is installed! But not by nvim-treesitter! Please manually remove the following files: " + .. table.concat(all_parsers, ", "), + vim.log.levels.ERROR + ) + end end end end -- cgit v1.2.3