diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 3141bddb..8654edec 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -150,20 +150,19 @@ return { }, }, - -- disable old installations of mini.ai. Optional so it doesn't appear under disabled plugins + -- mini.ai has been moved from coding to extras. + -- if the config of the user contains mini.ai without the extra: + -- warn and disable { "echasnovski/mini.ai", - enabled = function() + enabled = function() -- the extra must override this function. vim.schedule(function() local Config = require("lazy.core.config") if Config.spec.disabled["mini.ai"] then require("lazy.core.util").warn( - [[ `mini.ai` has been moved to extras: -The core config for nvim-treesitter now contains textobjects -for `select`, `move` and `swap`. -If you want to keep using mini.ai, you can add the mini-ai extra: + [[ `mini.ai` has been moved to **extras**. +Please add the `mini.ai` **extra** to your config: `lazyvim.plugins.extras.coding.mini-ai` -By doing so, your original mini.ai setup remains unchanged. ]], { title = "LazyVim" } ) @@ -171,6 +170,6 @@ By doing so, your original mini.ai setup remains unchanged. end) return false end, - optional = true, + optional = true, -- only warn if the config of the user contains mini.ai }, } diff --git a/lua/lazyvim/plugins/extras/coding/mini-ai.lua b/lua/lazyvim/plugins/extras/coding/mini-ai.lua index 7d9856eb..2c43e831 100644 --- a/lua/lazyvim/plugins/extras/coding/mini-ai.lua +++ b/lua/lazyvim/plugins/extras/coding/mini-ai.lua @@ -4,7 +4,7 @@ local load_textobjects = false local function source_runtime_textobjects(ts_opts) -- PERF: no need to load the plugin, if we only need its queries for mini.ai - if ts_opts.textobjects then -- the user defines textobjects + if ts_opts.textobjects then -- the user defined textobjects for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do if ts_opts.textobjects[mod] and ts_opts.textobjects[mod].enable then local Loader = require("lazy.core.loader") @@ -17,20 +17,15 @@ local function source_runtime_textobjects(ts_opts) end end -local function spec_decorate_config_property() - -- avoid code duplication: - -- decorate config function defined in lazyvim.plugins.treesitter +---@param treesitter_plugin LazyPlugin +local function decorate_config_function(treesitter_plugin) + -- the config function is defined in lazyvim.plugins.treesitter + local config_to_decorate = treesitter_plugin.config - local Config = require("lazy.core.config") - - ---@type LazyPlugin - local spec_treesitter = Config.spec.plugins["nvim-treesitter"] - local config_to_decorate = spec_treesitter.config - spec_treesitter.config = function(_, opts) + treesitter_plugin.config = function(_, opts) if config_to_decorate then - config_to_decorate(spec_treesitter, opts) + config_to_decorate(treesitter_plugin, opts) end - if load_textobjects then source_runtime_textobjects(opts) end @@ -40,8 +35,8 @@ end return { { "nvim-treesitter/nvim-treesitter", - init = function() - spec_decorate_config_property() + init = function(plugin) + decorate_config_function(plugin) -- avoiding code duplication end, dependencies = { { @@ -66,7 +61,7 @@ return { -- Better text-objects { "echasnovski/mini.ai", - enabled = true, + enabled = true, -- overrides the function defined in lazyvim.plugins.coding -- keys = { -- { "a", mode = { "x", "o" } }, -- { "i", mode = { "x", "o" } },