Bracket Pair Colorization in cm6?

How would I implement the coloring of brackets/parentheses based on their depth, like in visual studio?

Walking the syntax tree and emitting decorations for the brackets you find would be the general approach to this. Probably, to optimize, you’d only want to do it for the content of the viewport (though depending on how stable you want your colors to be, you may need to look at out-of-viewport content to determine nesting depth).

Thank you for the reply!

Where should I look for an example of walking the syntax tree? I assume this uses Lezer?

I don’t really have the time to guide everyone here through the individual steps to implement the specific things they want to implement—go through the docs, and ask specific questions here if you can’t figure out details.

I have a rough but working version of depth-based bracket colorization if it can help!

1 Like