echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.47k stars 175 forks source link

mini.ai newline bug #902

Closed simonmandlik closed 1 month ago

simonmandlik commented 1 month ago

Contributing guidelines

Module(s)

mini.ai

Description

I'm using default settings, search method is thus cover_or_next.

[<cursor>,
 b, [c] ]

Placing the cursor anywhere in <cursor>, di] correctly deletes everything inside outer square brackets.

However, in

[<cursor>, b, [c]
  ]

di] deletes only the c.

In

[<cursor>, b,
  [c]
  ]

I get the correct behavior again.

Neovim version

0.10.0

Steps to reproduce

repro.lua:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    {
        {
            "echasnovski/mini.ai",
            opts = {},
        },
    }
}

require("lazy").setup(plugins, {
    root = root .. "/plugins",
})
echasnovski commented 1 month ago

Thanks for the issue!

This is an intended behavior of first searching only inside current line/selection before searching in the whole neighborhood. See this comment for a suggested workaround.

Closing as duplicate of #790, #392, #123, #116.

simonmandlik commented 1 month ago

@echasnovski

First off, apologies for failing the search for duplicates 🫣

Would you perhaps be willing to revisit https://github.com/echasnovski/mini.nvim/issues/790#issuecomment-2083117530? I try to keep the neovim behavior as close as possible to nvim --clean, only enhancing it, not modifying. In vanilla neovim, all examples I showed above end up with []. And I really like this modus operandi — perform action at the cursor location and if not possible, move forward. This is true for not only text objects, but also e.g. for <C-a/x>, and many surround plugins.

I know there are n and l modifiers and in my opinion it is perfectly valid and concise configuration as well, it is just not consistent with the original neovim behavior. In the ideal world, I would like mini.ai to behave as original neovim, provide some additional text objects, and also provided n and l in cases I really need it.

I really like everything else mini.ai brings to the table, but not being able to emulate original neovim behavior in this case is a big con for me.

echasnovski commented 1 month ago

Would you perhaps be willing to revisit #790 (comment)?

Sorry, but nothing has changed in 3 weeks and this is still the suggested approach. To the extent that if I'd to implement 'mini.ai' now from scratch, it will probably be the default without all 'cover_or_xxx' search method.

simonmandlik commented 1 month ago

Yes, I've seen the suggested approach. But search_mode = "cover" means:

mini.ai is an amazing plugin and thanks a lot for it, it's just a pity that migrating to it involves having to rewire your muscle memory.