-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utility): add
mason-tool-installer.nvim
installation utility (#…
…755)
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
lua/astrocommunity/utility/mason-tool-installer-nvim/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# mason-tool-installer.nvim | ||
|
||
Install and upgrade third party tools automatically | ||
|
||
**Repository:** <https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim> | ||
|
||
_Note_: This integrates with `mason-null-ls`, `mason-lspconfig`, and `mason-nvim-dap` by moving any `ensure_installed` lists into `mason-tool-installer` and removes them from those plugins. |
50 changes: 50 additions & 0 deletions
50
lua/astrocommunity/utility/mason-tool-installer-nvim/init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- helper function to setup a plugin without an `ensure_installed` table | ||
local setup_without_ensure_installed = function(main, opts) | ||
opts = vim.deepcopy(opts) | ||
opts.ensure_installed = nil | ||
require(main).setup(opts) | ||
end | ||
|
||
return { | ||
{ | ||
"WhoIsSethDaniel/mason-tool-installer.nvim", | ||
cmd = { "MasonToolsInstall", "MasonToolsUpdate", "MasonToolsClean" }, | ||
dependencies = { "williamboman/mason.nvim" }, | ||
init = function(plugin) require("astrocore").on_load("mason.nvim", plugin.name) end, | ||
config = function(_, opts) | ||
-- integrate other installer plugins into mason-tool-installer | ||
if not opts.ensure_installed then opts.ensure_installed = {} end | ||
local target_lookup = {} | ||
for _, target in ipairs(opts.ensure_installed) do | ||
target_lookup[target] = true | ||
end | ||
for _, plugin in ipairs { "mason-nvim-dap.nvim", "mason-lspconfig.nvim", "mason-null-ls.nvim" } do | ||
for _, target in ipairs(require("astrocore").plugin_opts(plugin).ensure_installed or {}) do | ||
if not target_lookup[target] then table.insert(opts.ensure_installed, target) end | ||
end | ||
end | ||
local mason_tool_installer = require "mason-tool-installer" | ||
mason_tool_installer.setup(opts) | ||
mason_tool_installer.run_on_start() | ||
end, | ||
}, | ||
-- disable init and ensure installed of other plugins | ||
{ | ||
"jay-babu/mason-nvim-dap.nvim", | ||
optional = true, | ||
init = false, | ||
config = function(_, opts) setup_without_ensure_installed("mason-nvim-dap", opts) end, | ||
}, | ||
{ | ||
"williamboman/mason-lspconfig.nvim", | ||
optional = true, | ||
init = false, | ||
config = function(_, opts) setup_without_ensure_installed("mason-lspconfig", opts) end, | ||
}, | ||
{ | ||
"jay-babu/mason-null-ls.nvim", | ||
optional = true, | ||
init = false, | ||
config = function(_, opts) setup_without_ensure_installed("mason-null-ls", opts) end, | ||
}, | ||
} |