Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
-- 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:
--
Expand All @@ -53,7 +52,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 = {}
}
```

Expand All @@ -76,3 +76,11 @@ return {
}
}
```

## Configuration

```lua
{
open_config_after_creation = true
}
```
15 changes: 15 additions & 0 deletions lua/activate/config.lua
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions lua/activate/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions lua/activate/types.lua
Original file line number Diff line number Diff line change
@@ -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`
11 changes: 7 additions & 4 deletions lua/activate/utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@module "activate.types"
local M = {}

local api = vim.api
Expand Down Expand Up @@ -132,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.
--
-- 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:
--
Expand All @@ -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()
Expand Down Expand Up @@ -326,14 +327,16 @@ 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()
local entry = action_state.get_selected_entry()
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

Expand Down