aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2022-08-01 21:58:01 +0200
committerStephan Seitz <stephan.seitz@fau.de>2022-08-26 13:35:17 -0700
commit11a8812a477969e913913b51550e14cdb4bfcb8c (patch)
treec4383b1c163c01023bb13d51548d2ee88931c21f /lua
parentchore: remove unused parameter (diff)
downloadnvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar.gz
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar.bz2
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar.lz
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar.xz
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.tar.zst
nvim-treesitter-11a8812a477969e913913b51550e14cdb4bfcb8c.zip
fix: add hint when there parser is still installed after TSUninstall
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/install.lua35
1 files changed, 30 insertions, 5 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index 648b55528..8e2e81468 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