Skip to content

Commit

Permalink
feat(health): check for nvim-treesitter conflicts (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jul 2, 2024
1 parent 7b454ba commit 170a1b0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 33 additions & 2 deletions lua/rocks/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ local function check_config()
end
end

---@return boolean
local function check_rocks_toml()
start("Checking rocks.toml")
local found_err = false
Expand All @@ -139,7 +140,7 @@ local function check_rocks_toml()
found_err = true
end)
if not success then
return
return false
end
for rock_name, _ in pairs(user_rocks_or_err) do
if rock_name:lower() ~= rock_name then
Expand All @@ -150,6 +151,31 @@ local function check_rocks_toml()
if not found_err then
ok("No errors found in rocks.toml.")
end
return not found_err
end

local function check_tree_sitter()
start("Checking tree-sitter parsers")
local user_rocks = require("rocks.config.internal").get_user_rocks()
local has_tree_sitter_parser = false
local has_nvim_treesitter_master = false
for rock_name, _ in pairs(user_rocks) do
if rock_name:find("^tree%-sitter%-[^%s]+$") ~= nil then
has_tree_sitter_parser = true
end
if rock_name == "nvim-treesitter" and pcall(require, "nvim-treesitter.utils") then
has_nvim_treesitter_master = true
end
end
if has_tree_sitter_parser and has_nvim_treesitter_master then
error([[
'nvim-treesitter' (master) conflicts with luarocks 'tree-sitter-<lang>' parsers.
Either use 'nvim-treesitter' (main) or use the 'nvim-treesitter-legacy-api' rock,
if you are using plugins that depend on the legacy nvim-treesitter API.
]])
else
ok("No tree-sitter issues detected.")
end
end

function health.check()
Expand All @@ -158,7 +184,12 @@ function health.check()
check_external_dependency(dep)
end
check_config()
check_rocks_toml()
local toml_ok = check_rocks_toml()
if toml_ok then
check_tree_sitter()
else
warn("Skipping tree-sitter parsers check due to errors in rocks.toml")
end
end

return health
3 changes: 3 additions & 0 deletions nix/plugin-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ in {
withPython3 = true;
viAlias = false;
vimAlias = false;
plugins = [
final.vimPlugins.rocks-nvim
];
};
rocks = lua51Packages.rocks-nvim;
in
Expand Down

0 comments on commit 170a1b0

Please sign in to comment.