In ftplugin/shaderslang.vim, b:match_words puts { in the same open half as if/for/while/switch/struct/class, and } in the same close half as break.
matchit counts every alternative in a group instead of pairing them with each other, so for (...) { counts as two openers and a brace can pair with a break.
With vim --clean -c 'packadd matchit' -c 'edit x.slang' (in Nvim nvim --clean x.slang is enough, it enables matchit by default):
void f() { // % -> line 7 (should be 13) switch (mode) { // % -> line 4 (should be 7) case 1: break; default: break; } // % -> line 1 (should be 2) for (int i = 0; i < 4; ++i) { // % -> line 12 (correct) if (i == 2) break; total += i; } } // % -> line 8 (should be 1)
With one more keyword line in the mix (e.g. an if above the break in case 1) the surplus stops balancing altogether and % on the function's opening brace finds no match at all, leaving the cursor where it is.
Drop the brace/keyword group and \[:\] — matchit appends 'matchpairs' by itself.
The preprocessor group is left unchanged: Slang has no #elifdef/#elifndef (kDirectives in slang-preprocessor.cpp), so it should not follow ftplugin/c.vim there. b:match_skip is untouched.
Trade-offs: braces match correctly again, brackets and parens are unaffected, and % on if/for/while now goes to the header's closing paren as in C files - but % on a break; no longer jumps back to the enclosing opener.
Keeping that would need a group of its own (e.g. ^\s*\<\(do\|for\|switch\|while\)\>:^\s*\<break\>), which in turn leaves % dead on any for/while without a break in it.
Test_shaderslang_matchit_switch_break and Test_shaderslang_matchit_loop_break in src/testdir/test_plugin_matchit.vim fail before this change and pass after it.
cc @mTvare6 as the file's maintainer.
Prepared with AI assistance (Claude Opus 5) per CONTRIBUTING.md, recorded in the commit's Co-Authored-By trailer.
Mainly, I wanted to report this - the patch is a suggestion, written with AI assistance and reviewed as far as my understanding goes. So, please change or replace it as you see fit. If I can help with anything, let me know :)
https://github.com/vim/vim/pull/21064
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
thanks, I think this makes sense, but I'll leave this open for a few more days to keep @mTvare6 a chance to review it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
I missed that matchpairs already handles braces at the correct level. This matches the approach used by c.vim now. LGTM.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()