From f4b599857b6d5cb9f5e14ceb7ec4d38c0d5cf733 Mon Sep 17 00:00:00 2001 From: justbarnt Date: Fri, 11 Jul 2025 16:30:43 -0400 Subject: [PATCH 1/3] wip: changing so that plugins without a `setup.lua.example` are created with `opts = {}` per lazy.nvim recommendation will fix #11 --- lua/activate/utils.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/activate/utils.lua b/lua/activate/utils.lua index 4adc564..49046d6 100644 --- a/lua/activate/utils.lua +++ b/lua/activate/utils.lua @@ -133,7 +133,7 @@ M.create_plugin_file = function(plugin_name, repo, _config, edit) else local disclaimer = [[ -- No example configuration was found for this plugin. - -- + -- So a default has been configured. -- For detailed information on configuring this plugin, please refer to its -- official documentation: -- @@ -148,7 +148,8 @@ M.create_plugin_file = function(plugin_name, repo, _config, edit) f:write(disclaimer) f:write("\n") f:write("return {\n") - f:write(string.format(' -- "%s"\n', repo)) + f:write(string.format(' "%s",\n', repo)) + f:write(' opts = {}\n') f:write("}") end f:close() From a721dc8c8ec35b8dedfb0bccc7dca04afab5b4f1 Mon Sep 17 00:00:00 2001 From: justbarnt Date: Mon, 14 Jul 2025 09:17:02 -0400 Subject: [PATCH 2/3] feat: Use `opts = {}` when plugin does not have `setup.lua.exmample` Defaulted to `opts = {}` and uncommented out the repo link when `setup.lua.example` is not there. Also added a configuration option `open_config_after_creation` which defaults to true, to retain previous behavior. If set false; it will not open the configuration after creation --- README.md | 13 +++++++++++-- lua/activate/config.lua | 15 +++++++++++++++ lua/activate/init.lua | 2 ++ lua/activate/types.lua | 2 ++ lua/activate/utils.lua | 5 ++++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 lua/activate/config.lua create mode 100644 lua/activate/types.lua diff --git a/README.md b/README.md index 8d6c916..22f52cf 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ When plugins don't conform to the unofficial standard outlined above, then a pla ```lua -- No example configuration was found for this plugin. --- +-- Using the default configuration for this plugin. -- For detailed information on configuring this plugin, please refer to its -- official documentation: -- @@ -53,7 +53,8 @@ When plugins don't conform to the unofficial standard outlined above, then a pla -- the configuration below. return { - -- "cbochs/grapple.nvim" + "cbochs/grapple.nvim", + opts = {} } ``` @@ -76,3 +77,11 @@ return { } } ``` + +## Configuration + +```lua +{ + open_config_after_creation = true +} +``` diff --git a/lua/activate/config.lua b/lua/activate/config.lua new file mode 100644 index 0000000..3c1688e --- /dev/null +++ b/lua/activate/config.lua @@ -0,0 +1,15 @@ +local M = {} + +---@class Activate.Config +M.config = {} + +---@class Activate.Config +local defaults = { + open_config_after_creation = true, +} + +M.setup = function(user_config) + M.config = vim.tbl_deep_extend("force", defaults, user_config or {}) +end + +return M diff --git a/lua/activate/init.lua b/lua/activate/init.lua index f70b64f..f50de16 100644 --- a/lua/activate/init.lua +++ b/lua/activate/init.lua @@ -113,6 +113,8 @@ local function create_picker(title, prompt, items, mappings_func) plugin_picker:find() end +M.setup = require("activate.config").setup + M.list_plugins = function() local items = utils.get_all_plugins() create_picker( diff --git a/lua/activate/types.lua b/lua/activate/types.lua new file mode 100644 index 0000000..e742ee4 --- /dev/null +++ b/lua/activate/types.lua @@ -0,0 +1,2 @@ +---@class Activate.Config +---@field open_config_after_creation boolean Should the newly created configuration open after it is created, default: `true` diff --git a/lua/activate/utils.lua b/lua/activate/utils.lua index 49046d6..4f743b7 100644 --- a/lua/activate/utils.lua +++ b/lua/activate/utils.lua @@ -1,3 +1,4 @@ +---@module "activate.types" local M = {} local api = vim.api @@ -327,6 +328,8 @@ local function help() end M.all_plugins_mappings = function(prompt_bufnr, map) + ---@class Activate.Config + local user_conf = require("activate.config").config local action_state = require("telescope.actions.state") local function install_and_or_configure_plugin() @@ -334,7 +337,7 @@ M.all_plugins_mappings = function(prompt_bufnr, map) vim.api.nvim_buf_delete(prompt_bufnr, { force = true }) M._install_plugin(entry) local repo_path = entry.url:gsub("https://github.com/", "") - local edit = true + local edit = user_conf.open_config_after_creation M.create_plugin_file(entry.plugin_name, repo_path, entry.config, edit) end From 50a585d9b54ae7fa2bd961fb96471bd8da5cacce Mon Sep 17 00:00:00 2001 From: justbarnt Date: Mon, 14 Jul 2025 09:56:20 -0400 Subject: [PATCH 3/3] #12: Updated comment for default plugin configuration creation --- README.md | 3 +-- lua/activate/utils.lua | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22f52cf..db7526a 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,7 @@ return { When plugins don't conform to the unofficial standard outlined above, then a placeholder config is generated, for example, `$HOME/.config/nvim/lua/plugins/grapple.lua`: ```lua --- No example configuration was found for this plugin. --- Using the default configuration for this plugin. +-- No example configuration was found for this plugin, a default has been configured. -- For detailed information on configuring this plugin, please refer to its -- official documentation: -- diff --git a/lua/activate/utils.lua b/lua/activate/utils.lua index 4f743b7..f77e5ac 100644 --- a/lua/activate/utils.lua +++ b/lua/activate/utils.lua @@ -133,8 +133,7 @@ M.create_plugin_file = function(plugin_name, repo, _config, edit) f:write(config) else local disclaimer = [[ - -- No example configuration was found for this plugin. - -- So a default has been configured. + -- No example configuration was found for this plugin, a default has been configured. -- For detailed information on configuring this plugin, please refer to its -- official documentation: --