2023-10-10 21:51:09 +02:00
|
|
|
local Plugin = require("lazy.core.plugin")
|
|
|
|
|
|
|
|
---@class lazyvim.util.plugin
|
|
|
|
local M = {}
|
|
|
|
|
2024-06-14 11:13:56 +02:00
|
|
|
---@type string[]
|
|
|
|
M.core_imports = {}
|
|
|
|
|
2023-10-10 21:51:09 +02:00
|
|
|
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
|
|
|
|
|
|
|
|
---@type table<string, string>
|
|
|
|
M.deprecated_extras = {
|
|
|
|
["lazyvim.plugins.extras.formatting.conform"] = "`conform.nvim` is now the default **LazyVim** formatter.",
|
|
|
|
["lazyvim.plugins.extras.linting.nvim-lint"] = "`nvim-lint` is now the default **LazyVim** linter.",
|
2023-10-10 22:41:34 +02:00
|
|
|
["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.",
|
2024-05-16 18:03:58 +02:00
|
|
|
["lazyvim.plugins.extras.coding.native_snippets"] = "Native snippets are now the default for **Neovim >= 0.10**",
|
2024-05-17 22:38:45 +02:00
|
|
|
["lazyvim.plugins.extras.ui.treesitter-rewrite"] = "Disabled `treesitter-rewrite` extra for now. Not ready yet.",
|
2024-05-18 16:31:13 -04:00
|
|
|
["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)",
|
2024-05-26 16:49:48 +02:00
|
|
|
["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature",
|
2024-05-30 14:41:13 +02:00
|
|
|
["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main",
|
2024-06-05 11:01:10 +02:00
|
|
|
["lazyvim.plugins.extras.lang.python-semshi"] = [[The python-semshi extra has been removed,
|
|
|
|
because it's causing too many issues.
|
|
|
|
Either use `basedpyright`, or copy the [old extra](https://github.com/LazyVim/LazyVim/blob/c1f5fcf9c7ed2659c9d5ac41b3bb8a93e0a3c6a0/lua/lazyvim/plugins/extras/lang/python-semshi.lua#L1) to your own config.
|
|
|
|
]],
|
2023-10-10 21:51:09 +02:00
|
|
|
}
|
|
|
|
|
2024-06-01 08:48:44 +02:00
|
|
|
M.deprecated_modules = {}
|
2023-10-12 10:36:15 +02:00
|
|
|
|
2023-10-10 21:51:09 +02:00
|
|
|
---@type table<string, string>
|
|
|
|
M.renames = {
|
|
|
|
["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre",
|
|
|
|
["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim",
|
|
|
|
["null-ls.nvim"] = "none-ls.nvim",
|
2023-10-12 10:35:47 +02:00
|
|
|
["romgrk/nvim-treesitter-context"] = "nvim-treesitter/nvim-treesitter-context",
|
2023-10-14 13:21:30 +02:00
|
|
|
["glepnir/dashboard-nvim"] = "nvimdev/dashboard-nvim",
|
2024-08-31 03:16:45 -04:00
|
|
|
["markdown.nvim"] = "render-markdown.nvim",
|
2023-10-10 21:51:09 +02:00
|
|
|
}
|
|
|
|
|
2024-06-14 11:13:56 +02:00
|
|
|
function M.save_core()
|
|
|
|
if vim.v.vim_did_enter == 1 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
M.core_imports = vim.deepcopy(require("lazy.core.config").spec.modules)
|
|
|
|
end
|
|
|
|
|
2023-10-11 22:38:10 +02:00
|
|
|
function M.setup()
|
|
|
|
M.fix_imports()
|
|
|
|
M.fix_renames()
|
|
|
|
M.lazy_file()
|
2023-10-12 10:36:15 +02:00
|
|
|
table.insert(package.loaders, function(module)
|
|
|
|
if M.deprecated_modules[module] then
|
2024-03-22 09:15:09 +01:00
|
|
|
LazyVim.warn(
|
2023-10-12 10:36:15 +02:00
|
|
|
("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it."):format(
|
|
|
|
module,
|
|
|
|
M.deprecated_modules[module]
|
|
|
|
),
|
|
|
|
{ title = "LazyVim" }
|
|
|
|
)
|
|
|
|
return function() end
|
|
|
|
end
|
|
|
|
end)
|
2023-10-11 22:38:10 +02:00
|
|
|
end
|
|
|
|
|
2023-10-12 00:11:33 +02:00
|
|
|
function M.extra_idx(name)
|
|
|
|
local Config = require("lazy.core.config")
|
|
|
|
for i, extra in ipairs(Config.spec.modules) do
|
|
|
|
if extra == "lazyvim.plugins.extras." .. name then
|
|
|
|
return i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-10 21:51:09 +02:00
|
|
|
function M.lazy_file()
|
2024-05-14 21:43:02 +02:00
|
|
|
-- Add support for the LazyFile event
|
|
|
|
local Event = require("lazy.core.handler.event")
|
|
|
|
|
|
|
|
Event.mappings.LazyFile = { id = "LazyFile", event = M.lazy_file_events }
|
|
|
|
Event.mappings["User LazyFile"] = Event.mappings.LazyFile
|
2023-10-10 21:51:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.fix_imports()
|
2025-02-08 15:04:46 +01:00
|
|
|
local defaults ---@type table<string, LazyVimDefault>
|
2024-03-22 09:15:09 +01:00
|
|
|
Plugin.Spec.import = LazyVim.inject.args(Plugin.Spec.import, function(_, spec)
|
2025-02-08 15:04:46 +01:00
|
|
|
if LazyVim.config.json_loaded then
|
|
|
|
-- extra disabled by defaults?
|
|
|
|
defaults = defaults or LazyVim.config.get_defaults()
|
|
|
|
local def = defaults[spec.import]
|
|
|
|
if def and def.enabled == false then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
2023-10-10 21:51:09 +02:00
|
|
|
local dep = M.deprecated_extras[spec and spec.import]
|
|
|
|
if dep then
|
2024-05-16 18:03:58 +02:00
|
|
|
dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning."
|
2024-03-22 09:15:09 +01:00
|
|
|
LazyVim.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 })
|
2023-10-11 22:38:10 +02:00
|
|
|
return false
|
2023-10-10 21:51:09 +02:00
|
|
|
end
|
2023-10-11 22:38:10 +02:00
|
|
|
end)
|
2023-10-10 21:51:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.fix_renames()
|
2024-03-22 09:15:09 +01:00
|
|
|
Plugin.Spec.add = LazyVim.inject.args(Plugin.Spec.add, function(self, plugin)
|
2023-10-10 21:51:09 +02:00
|
|
|
if type(plugin) == "table" then
|
|
|
|
if M.renames[plugin[1]] then
|
2024-03-22 09:15:09 +01:00
|
|
|
LazyVim.warn(
|
2023-10-10 21:51:09 +02:00
|
|
|
("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format(
|
|
|
|
plugin[1],
|
|
|
|
M.renames[plugin[1]],
|
|
|
|
self.importing or "LazyVim"
|
|
|
|
),
|
|
|
|
{ title = "LazyVim" }
|
|
|
|
)
|
|
|
|
plugin[1] = M.renames[plugin[1]]
|
|
|
|
end
|
|
|
|
end
|
2023-10-11 22:38:10 +02:00
|
|
|
end)
|
2023-10-10 21:51:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|