Skip to content

Commit 84bbfbf

Browse files
tetomrcjkb
andauthored
feat: warn about wrong 'dir' values (#35)
* feat: warn about wrong 'dir' values Warn about non-existing directories to help the user debug its config * chore: trace rocks-dev setup * feat: add a notification upon inexisting directory * fix(Makefile): fix paths * chore: quotes --------- Co-authored-by: Marc Jakobi <[email protected]>
1 parent b24578c commit 84bbfbf

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
format:
2-
stylua -v --verify lua/rocks-config/ plugin/
2+
stylua -v --verify lua/rocks-dev/ plugin/
33

44
check:
5-
luacheck lua/rocks-config plugin/
5+
luacheck lua/rocks-dev plugin/

lua/rocks-dev/init.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local rocks = require("rocks.api")
2+
local log = require("rocks.log")
23

34
local rocks_dev = {}
45

@@ -21,11 +22,14 @@ function rocks_dev.setup(user_configuration)
2122
return
2223
end
2324

25+
log.trace("rocks-dev setup")
26+
2427
local has_rocks_config, rocks_config = pcall(require, "rocks-config")
2528
local config_hook = has_rocks_config and type(rocks_config.configure) == "function" and rocks_config.configure
2629
or function(_) end
2730

2831
local dev_path = user_configuration.dev and user_configuration.dev.path
32+
local errors_found = false
2933

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

4250
-- NOTE: We can't support `opt` for dev plugins,
4351
-- as it doesn't integrate with `:packadd`
4452
require("rtp_nvim").source_rtp_dir(path)
4553
end
4654
end
55+
56+
if errors_found then
57+
vim.notify("Issues while loading rocks-dev configs. Run ':Rocks log' for more info.", vim.log.levels.WARN)
58+
end
4759
end
4860

4961
rocks.register_rock_handler(require("rocks-dev.local-rock-handler"))

0 commit comments

Comments
 (0)