Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Not sure if it'll be more or less confusing for you, but you could look at the <code>lisp.vim</code> syntax file (especially the part where <code>g:lisp_rainbow</code> is handled) to see how you can highlight matching parens.</p> <p>If you manage to highlight all the matching parens, you could have the leftover parens (i.e. unmatched parens) have default Error highlighting. This is what the lisp file seems to be doing.</p> <h3>EDIT: How about this:</h3> <pre><code>syn match parenError ")" syn region matchingParens transparent start="(" end=")" contains=matchingParens hi parenError guifg=red </code></pre> <p>If you <code>:syn clear</code> and run those, it seems to work. Note that the order the <code>syn</code> commands are executed matters. Per <code>:h :syn-priority</code>, the rule matched <strong>last</strong> is the one that takes effect, which may be why your rules highlighted all the end-parens in the file.</p> <h3>EDIT #2:</h3> <p>What c.vim is actually doing is highlighting <strong>any</strong> <code>{}</code> inside of <code>()</code>, whether everything is properly closed or not. Try typing <code>({})</code> in C mode, it still highlights the <code>{}</code> as an error. </p> <p>I don't think this approach can be used to test directly for a <code>(</code> with an unmatched <code>)</code>, because <code>:syn region</code> doesn't care whether the end-pattern is there or not.</p> <p>So you have to find something Python-specific that should never belong inside <code>()</code>. Then match against <code>"(\_[^)]*the_forbidden_something"</code>. I don't know Python enough to know what that might be.</p> <p>If nothing else, you can do:</p> <pre><code>syn match openParen "(\_[^)]*\%$" </code></pre> <p>which matches an open paren with no closing parens before the end-of-file. This fails if it finds any closing paren at all, which means it won't even catch <code>(()&lt;EOF&gt;</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload