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

fix: rocks-config integration #9

Merged
merged 1 commit into from
Jul 29, 2024
Merged
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
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
Loading