diff --git a/README.md b/README.md index 016317b..0caebf9 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,9 @@ for you. > it will be invoked with the call to `require`, > potentially resulting in more eager initialization than necessary. +You can also enable/disable `auto_setup` for individual plugins +by setting `config = true` or `config = false`, respectively. + ### Initialization order rocks.nvim makes use of Neovim's built-in [initialization sequence](https://neovim.io/doc/user/starting.html#initialization), diff --git a/lua/rocks-config/internal.lua b/lua/rocks-config/internal.lua index d63137a..4d0e8cc 100644 --- a/lua/rocks-config/internal.lua +++ b/lua/rocks-config/internal.lua @@ -171,19 +171,20 @@ local function get_config() return vim.tbl_deep_extend("force", {}, constants.DEFAULT_CONFIG, rocks_toml or {}) end ----@param rock rock_name | RockSpec The rock to configure +---@param rock rock_name | RocksConfigRockSpec The rock to configure ---@param config? RocksConfigConfig function rocks_config.configure(rock, config) config = config or get_config() if type(rock) == "string" then local all_plugins = api.get_user_rocks() + ---@cast all_plugins table if not all_plugins[rock] then vim.notify(("[rocks-config.nvim]: Plugin %s not found in rocks.toml"):format(rock), vim.log.levels.ERROR) return end rock = all_plugins[rock] end - ---@cast rock RockSpec + ---@cast rock RocksConfigRockSpec local name = rock.name if _configured_rocks[name] then return @@ -207,12 +208,12 @@ function rocks_config.configure(rock, config) -- If there is no custom configuration defined by the user -- then check for a rock config or attempt to auto-invoke the setup() function. - if not found_custom_configuration and (config.config.auto_setup or rock.config) then + if not found_custom_configuration then if type(rock.config) == "string" then xpcall(require, function(err) table.insert(rocks_config.failed_to_load, { rock.name, rock.config, err }) end, rock.config) - else + elseif rock.config == true or config.config.auto_setup and rock.config ~= false then auto_setup(plugin_heuristics, config, rock) end end diff --git a/lua/rocks-config/meta.lua b/lua/rocks-config/meta.lua new file mode 100644 index 0000000..f5d161e --- /dev/null +++ b/lua/rocks-config/meta.lua @@ -0,0 +1,4 @@ +error("Can't require a meta module") + +---@class RocksConfigRockSpec: RockSpec +---@field config? string | boolean