Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn about wrong 'dir' values #35

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
format:
stylua -v --verify lua/rocks-config/ plugin/
stylua -v --verify lua/rocks-dev/ plugin/

check:
luacheck lua/rocks-config plugin/
luacheck lua/rocks-dev plugin/
12 changes: 12 additions & 0 deletions lua/rocks-dev/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local rocks = require("rocks.api")
local log = require("rocks.log")

local rocks_dev = {}

Expand All @@ -21,11 +22,14 @@ function rocks_dev.setup(user_configuration)
return
end

log.trace("rocks-dev setup")

local has_rocks_config, rocks_config = pcall(require, "rocks-config")
local config_hook = has_rocks_config and type(rocks_config.configure) == "function" and rocks_config.configure
or function(_) end

local dev_path = user_configuration.dev and user_configuration.dev.path
local errors_found = false

for _, rock_spec in pairs(user_configuration.plugins or {}) do
---@cast rock_spec rocks-dev.RockSpec
Expand All @@ -37,13 +41,21 @@ function rocks_dev.setup(user_configuration)
end
if path then
vim.opt.runtimepath:append(path)
if vim.fn.isdirectory(path) == 0 then
log.warn(rock_spec.name .. " dir value '" .. path .. "' is not a directory")
errors_found = true
end
config_hook(rock_spec.name)

-- NOTE: We can't support `opt` for dev plugins,
-- as it doesn't integrate with `:packadd`
require("rtp_nvim").source_rtp_dir(path)
end
end

if errors_found then
vim.notify("Issues while loading rocks-dev configs. Run ':Rocks log' for more info.", vim.log.levels.WARN)
end
end

rocks.register_rock_handler(require("rocks-dev.local-rock-handler"))
Expand Down
Loading