Any way to use mini.ai to work like something similar to matchit.vim #1699
-
Contributing guidelines
Module(s)mini.ai QuestionHi echasnovski! Is there any way to make mappings in mini.ai to achieve the functionality similar to matchit.vim which basically is pressing % key to traverse between if and else keywords or function and end keywords. This would be of great help for me if possible some way since the default matchit plugin does not support filetypes like svelte :( . |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There is Alternatively, there is a slightly more low-level A more The problem with A much less accurate approach is to use the rule "any text from require('mini.ai').setup({
custom_textobjects = {
o = { 'if.-else', '^if().*()else$' },
},
})
require('mini.surround').setup({
custom_surroundings = {
o = {
input = { 'if.-else', '^if().*()else$' },
output = { left = 'if', right = 'else' },
},
},
}) Hope this helps. |
Beta Was this translation helpful? Give feedback.
There is
move_cursor()
. It is also used forgoto_xxx
mappings. For example,g])
goes to the right)
. With'cover'
search method (either global or set directly inMiniAi.move_cursor()
call inside custom mappings) it will not go to the next)
textobject which can be used to imitate%
.Alternatively, there is a slightly more low-level
find_textobject()
which can be used to decide where to put cursor.A more
%
-like alternative isfind
orfind_left
actions from 'mini.surround'. Pressingsf)
multiple times will act like%
when traversing expression in parenthesis. Note, that it will possibly traverse through four cursor positions of surrounding (left start - left end - right start - right end).…