fix: warn when user uninstalls parser than is in their ensure_installed

Fixes #2777
This commit is contained in:
Stephan Seitz 2022-08-01 22:28:36 +02:00
parent 11a8812a47
commit d011532d73
2 changed files with 15 additions and 0 deletions

View file

@ -401,6 +401,7 @@ function M.setup(user_data)
end
config.modules.ensure_installed = nil
config.ensure_installed = ensure_installed
recurse_modules(function(_, _, new_path)
local data = utils.get_at_path(config.modules, new_path)
@ -578,4 +579,8 @@ function M.get_ignored_parser_installs()
return config.ignore_install or {}
end
function M.get_ensure_installed_parsers()
return config.ensure_installed or {}
end
return M

View file

@ -489,6 +489,16 @@ function M.uninstall(...)
return api.nvim_err_writeln(err)
end
if vim.tbl_contains(configs.get_ensure_installed_parsers(), lang) then
vim.notify(
"Uninstalling "
.. lang
.. '. But the parser is still configured in "ensure_installed" setting of nvim-treesitter.'
.. " Please consider updating your config!",
vim.log.levels.ERROR
)
end
local parser_lib = utils.join_path(install_dir, lang) .. ".so"
local all_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true)
if vim.fn.filereadable(parser_lib) == 1 then