-
Contributing guidelines
Module(s)mini.ai QuestionThere is an example that imitates the word textobject with optional trailing whitespace: require("mini.ai").setup({
custom_textobjects = {
w = { "()()%f[%w]%w+()[ \t]*()" },
},
})This works well, but I want to achieve the opposite behavior: imitate the word textobject with optional leading whitespace. However, this does not work: require("mini.ai").setup({
custom_textobjects = {
w = { "()[ \t]*()%f[%w]%w+()()" },
},
})This is very close to the behavior I want: require("mini.ai").setup({
custom_textobjects = {
w = { "()%f[ \t][ \t]*()%f[%w]%w+()()" },
},
})but it does not work correctly at the first word, i.e. Is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Yes, it is possible by using composed pattern. It is a bit convoluted, but it is essentially a way to say "match one of patterns at this place, whichever has the smallest width". Here is the example for this particular case: require('mini.ai').setup({
custom_textobjects = {
w = { { '^()%w+()', '()%f[ \t][ \t]*()%f[%w]%w+()()' } },
},
})However, my honest suggestion would be to try to avoid this. Although it makes it work with |
Beta Was this translation helpful? Give feedback.
Oh! Wait, I think I just thought of a method 😄
finally works