vim: Add use_match_quotes setting for % motion, default is true#42615
vim: Add use_match_quotes setting for % motion, default is true#42615dinocosta merged 17 commits intozed-industries:mainfrom
use_match_quotes setting for % motion, default is true#42615Conversation
|
Thank you for opening this Pull Request @Kalmaegi ! Will think a little bit more about this and try to take a look in the coming days, will keep you posted 🙂 |
|
Hey @Kalmaegi 👋 Thank you for opening this and sorry that it took me a while to get back to you, was checking with the team whether we'd like to introduce this, but Conrad told me he already chatted with you on Discord about it. Approach looks good to me, will see if we can simply the In the meantime, would you be able to:
Thanks! P.S.: Regarding the helper function you shared, |
Sure! Sorry for the lack of updates lately. I’ll fetch on main, resolve the conflicts, and add the test for the |
…s_setting_for_vim # Conflicts: # crates/vim/src/motion.rs
|
Hi @dinocosta |
- Update the documentation for `settings::settings_content::VimSettingsContent.use_match_quotes` in order for it to be shown in the documentation modal when user is editing their settings. - Update the documentation for `vim.use_match_quotes` in `assets/settings/default.json`. - Small refactoring of `vim::motion::matching` in order to leverage `Option<T>.is_some_and` and prefer use of `char` instead of `Option<char>` in closure.
|
Thank you @Kalmaegi ! I've pushed two more commits, one to just bring this branch up to date with
Honestly, I believe it's possible to just have it in the
Let me know what you think! No rush on this one, so we can also explore that option. |
Sorry i'm late, I didn't think of that approach! That makes a lot more sense. Just to confirm my understanding: with this approach, users only need to override the default I really like this solution! If my understanding is correct, I'll refactor the code |
Exactly. One could even have different bindings for both behaviors, as it would simply be a parameter in the dispatched action 🙂 Let me know if you need help with it, we can also schedule some pairing time if needed! |
|
I can’t run the Rust project on my macbook right now, but I’ll update and submit a fix as soon as possible. |
|
I’ve tweaked the code and tested it, hope everything works as expected. |
…s_setting_for_vim # Conflicts: # crates/vim/src/motion.rs
dinocosta
left a comment
There was a problem hiding this comment.
@Kalmaegi Thank you for taking the time to update these changes and including these tests, appreciate it! 🙇
I've pushed a commit adding some documentation to the match_quotes field, as well as also including "match_quotes": true in the Helix keymap, so that it continues working as Zed's defaults after this is merged. Thanks! ✌️
thanks, I forgot Helix mode XD |
Add a new Vim setting
use_match_quotesthat controls whether the % motion should treat quotes(`', ", `)as matching pairs.
In Vim, % only matches pairs of
([{}])— doesn’t consider quotes, to avoid breaking existing behavior in Zed, this new setting defaults to true, but users who prefer Vim’s original behavior can now disable it by setting:"use_match_quotes": falseWhile implementing this, I noticed there’s an existing helper:
zed/crates/vim/src/object.rs
Lines 284 to 289 in b01a6fb
I'm wondering if it might be cleaner to expose a small wrapper or helper here, so we can reuse the same quote detection logic instead of duplicating it.
If this overall approach looks good, I’ll proceed to add unit tests.
Release Notes:
match_quotesparameter to thevim::Matchingaction to control whether%matches quote characters