1
Fork 0

Huge progress on korora-based tempest generation

This commit is contained in:
Matei Adriel 2023-12-25 14:14:33 +01:00
parent 63d980ddf9
commit 42cd073278
No known key found for this signature in database
8 changed files with 1678 additions and 1462 deletions
home/features/neovim/config/lua/my

View file

@ -119,17 +119,26 @@ end
function M.configure(opts, context)
if type(opts) == "function" then
return M.configure(opts(context), context)
opts = opts(context)
end
if type(opts.mk_context) == "function" then
context = opts.mk_context(context)
if type(opts) ~= "table" then
-- TODO: throw
return
end
if type(opts.mkContext) == "function" then
context = opts.mkContext(context)
end
if type(opts.vim) == "table" then
recursive_assign(opts.vim, vim)
end
if type(opts.keys) == "function" then
opts.keys = opts.keys(context)
end
if type(opts.keys) == "table" then
local keys = opts.keys
@ -143,6 +152,10 @@ function M.configure(opts, context)
end
end
if type(opts.autocmds) == "function" then
opts.autocmds = opts.autocmds(context)
end
if type(opts.autocmds) == "table" then
local autocmds = opts.autocmds
@ -180,8 +193,10 @@ function M.configure(opts, context)
end
end
M.lazy = function(lazy, opts, spec)
return M.configure(spec, { lazy = lazy, opts = opts })
function M.configureMany(specs, context)
for _, spec in ipairs(specs) do
M.configure(spec, context)
end
end
-- }}}
-- {{{ Neovim env handling
@ -230,29 +245,46 @@ end
-- {{{ Fixup lazy spec generated by nix
function M.prepareLazySpec(spec)
for _, module in ipairs(spec) do
if spec.tempest ~= nil then
spec.config = function(lazy, opts)
M.configure(spec.tempest, { lazy = lazy, opts = opts })
if module.package ~= nil then
module[1] = module.package
module.package = nil
end
local configType = type(module.config)
if configType == "function" or configType == "table" then
local previousConfig = module.config
module.config = function(lazy, opts)
M.configure(previousConfig, { lazy = lazy, opts = opts })
end
end
if spec.dependencies ~= nil then
spec.dependencies = spec.dependencies.lua
end
if spec.keys ~= nil then
local keys = spec.keys
if spec.keys.mapping ~= nil then
keys = { keys }
if module.keys ~= nil then
if type(module.keys) == "string" or module.keys.mapping ~= nil then
module.keys = { module.keys }
end
for _, key in ipairs(keys) do
key[1] = key.mapping
if key.mode ~= nil then
key.mode = H.string_chars(key.mode)
for _, key in ipairs(module.keys) do
if type(key) ~= "string" then
key[1] = key.mapping
key.mapping = nil
if key.mode ~= nil then
key.mode = H.string_chars(key.mode)
end
if key.action ~= nil then
key[2] = key.action
key.action = nil
end
end
end
end
if type(module.cond) == "table" then
local final = true
for _, cond in ipairs(module.cond) do
final = final and cond
end
module.cond = final
end
end
end
-- }}}