mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
mini.ai: move to extras. Add default textobjects to treesitter. Improved the warning. Improved the config decoration.
This commit is contained in:
parent
cdf8036e7f
commit
7eb53e9a79
2 changed files with 17 additions and 23 deletions
|
|
@ -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",
|
"echasnovski/mini.ai",
|
||||||
enabled = function()
|
enabled = function() -- the extra must override this function.
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
local Config = require("lazy.core.config")
|
local Config = require("lazy.core.config")
|
||||||
if Config.spec.disabled["mini.ai"] then
|
if Config.spec.disabled["mini.ai"] then
|
||||||
require("lazy.core.util").warn(
|
require("lazy.core.util").warn(
|
||||||
[[ `mini.ai` has been moved to extras:
|
[[ `mini.ai` has been moved to **extras**.
|
||||||
The core config for nvim-treesitter now contains textobjects
|
Please add the `mini.ai` **extra** to your config:
|
||||||
for `select`, `move` and `swap`.
|
|
||||||
If you want to keep using mini.ai, you can add the mini-ai extra:
|
|
||||||
`lazyvim.plugins.extras.coding.mini-ai`
|
`lazyvim.plugins.extras.coding.mini-ai`
|
||||||
By doing so, your original mini.ai setup remains unchanged.
|
|
||||||
]],
|
]],
|
||||||
{ title = "LazyVim" }
|
{ title = "LazyVim" }
|
||||||
)
|
)
|
||||||
|
|
@ -171,6 +170,6 @@ By doing so, your original mini.ai setup remains unchanged.
|
||||||
end)
|
end)
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
optional = true,
|
optional = true, -- only warn if the config of the user contains mini.ai
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ local load_textobjects = false
|
||||||
local function source_runtime_textobjects(ts_opts)
|
local function source_runtime_textobjects(ts_opts)
|
||||||
-- PERF: no need to load the plugin, if we only need its queries for mini.ai
|
-- 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
|
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do
|
||||||
if ts_opts.textobjects[mod] and ts_opts.textobjects[mod].enable then
|
if ts_opts.textobjects[mod] and ts_opts.textobjects[mod].enable then
|
||||||
local Loader = require("lazy.core.loader")
|
local Loader = require("lazy.core.loader")
|
||||||
|
|
@ -17,20 +17,15 @@ local function source_runtime_textobjects(ts_opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spec_decorate_config_property()
|
---@param treesitter_plugin LazyPlugin
|
||||||
-- avoid code duplication:
|
local function decorate_config_function(treesitter_plugin)
|
||||||
-- decorate config function defined in lazyvim.plugins.treesitter
|
-- the config function is defined in lazyvim.plugins.treesitter
|
||||||
|
local config_to_decorate = treesitter_plugin.config
|
||||||
|
|
||||||
local Config = require("lazy.core.config")
|
treesitter_plugin.config = function(_, opts)
|
||||||
|
|
||||||
---@type LazyPlugin
|
|
||||||
local spec_treesitter = Config.spec.plugins["nvim-treesitter"]
|
|
||||||
local config_to_decorate = spec_treesitter.config
|
|
||||||
spec_treesitter.config = function(_, opts)
|
|
||||||
if config_to_decorate then
|
if config_to_decorate then
|
||||||
config_to_decorate(spec_treesitter, opts)
|
config_to_decorate(treesitter_plugin, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
if load_textobjects then
|
if load_textobjects then
|
||||||
source_runtime_textobjects(opts)
|
source_runtime_textobjects(opts)
|
||||||
end
|
end
|
||||||
|
|
@ -40,8 +35,8 @@ end
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
init = function()
|
init = function(plugin)
|
||||||
spec_decorate_config_property()
|
decorate_config_function(plugin) -- avoiding code duplication
|
||||||
end,
|
end,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +61,7 @@ return {
|
||||||
-- Better text-objects
|
-- Better text-objects
|
||||||
{
|
{
|
||||||
"echasnovski/mini.ai",
|
"echasnovski/mini.ai",
|
||||||
enabled = true,
|
enabled = true, -- overrides the function defined in lazyvim.plugins.coding
|
||||||
-- keys = {
|
-- keys = {
|
||||||
-- { "a", mode = { "x", "o" } },
|
-- { "a", mode = { "x", "o" } },
|
||||||
-- { "i", mode = { "x", "o" } },
|
-- { "i", mode = { "x", "o" } },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue