Skip to content

Commit

Permalink
fix: rocks-config integration (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Jul 29, 2024
1 parent e47955b commit 8e4de29
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lua/rocks-lazy/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ local rocks_lazy = {}

function rocks_lazy.load()
local api = require("rocks.api")
local log = require("rocks.log")
local lz_n = require("lz.n")

local user_rocks = api.get_user_rocks()

local has_rocks_config, rocks_config = pcall(require, "rocks-config")
---@param name string
local config_hook = function(name)
if has_rocks_config and type(rocks_config.configure) == "function" then
pcall(vim.cmd.packadd, { name, bang = true })
rocks_config.configure(name)
end
end

local config_hook = has_rocks_config
and type(rocks_config.configure) == "function"
---@param plugin lz.n.Plugin
and function(plugin)
local rock_spec = user_rocks[plugin.name]
if rock_spec then
pcall(vim.cmd.packadd, { plugin.name, bang = true })
rocks_config.configure(rock_spec)
else
log.warn(
("rocks-lazy: skipping rocks-config hook because %s not found in user rocks."):format(
plugin.name
)
)
end
end
or function(_) end

--- HACK: For some reason, if a RockSpec contains a list
--- (e.g. colorscheme = [ .. ]) then vim.deepcopy errors
Expand Down

0 comments on commit 8e4de29

Please sign in to comment.