Skip to content

Commit

Permalink
feat: adds possibility to load presets from setup method
Browse files Browse the repository at this point in the history
In addition to the `load_preset` method there's now a field inside the `setup` method called `load`.
You can put either a string (preset name) or an array of them there to load several presets.
  • Loading branch information
rasulomaroff committed Jan 31, 2024
1 parent 5c30277 commit a81e4c4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/reactive.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---@class Reactive.Config
---@field builtin? table<string, boolean | table<string, any>>
---@field preset_configs? table<string, boolean | table<string, any>>
---@field load? table<string> | string

local M = {}

Expand Down Expand Up @@ -32,6 +33,18 @@ function M.setup(config)
if config.preset_configs and not vim.tbl_isempty(config.preset_configs) then
State:set_configs(config.preset_configs)
end

if config.load then
if type(config.load) == 'table' and not vim.tbl_isempty(config.load) then
for _, preset in
ipairs(config.load --[[ @as table<string> ]])
do
M.load_preset(preset)
end
else
M.load_preset(config.load --[[ @as string ]])
end
end
end

---@param preset Reactive.Preset
Expand Down

0 comments on commit a81e4c4

Please sign in to comment.