firejump / vscode-frame-rainbow

Extension which shows indentation with a faint rainbow colored background to make them more readable
MIT License
4 stars 0 forks source link

Colorize by brackets? #2

Open wizzard0 opened 1 year ago

wizzard0 commented 1 year ago

First, this extension is already very helpful.

A further improvement which would greatly help when working with e.g. LISP files would be:

example:

image

here i'd expect the (if on line 102 to be colorized in violet not cyan, both (starts-with ... and (net-send-get-result on lines 103-104 to be colored cyan, and (append "." lne) to be colored orange

firejump commented 1 year ago

@wizzard0 Thank you for the kind words :)

This is an interesting feature request. Indeed the current coloring approach doesn't work well for some indentation rules commonly used in functional languages. However, what you're asking for would require the extension to parse the whole file taking the language syntax into account. VS Code extension API doesn't expose this, and extensions that are parsing by themselves are generally slow unless they implement the not-so-simple approach taken internally in VS Code itself (see https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization for details if you're curious).

While I was looking for further guidance on this, I stumbled upon this extension: https://github.com/leodevbro/vscode-blockman . (Un)fortunately, if configured in a particular way, it appears to be doing almost what vscode-frame-rainbow already does + also the bracket-based colorization you're asking for:

image

Here's relevant part of my settings.json that achieves this:

  "editor.guides.indentation": false,
  "blockman.n04ColorComboPreset": "Oxygen Dark (Solid colors)",
  "blockman.n04Sub04RightSideBaseOfBlocks": "Rightmost Edge Of File Content",
  "blockman.n33A01B2FromDepth0ToInwardForAllBackgrounds": "10,0,0,2; hsl(0, 100%, 10%) > hsl(90, 100%, 7%) > hsl(200, 80%, 13%) > hsl(270, 100%, 10%)",
  "blockman.n16EnableFocus": false,
  "blockman.n24AnalyzeRoundBrackets": true,
  "blockman.n27AlsoRenderBlocksInsideSingleLineAreas": true

You will need to tune the colors to fit with the light theme, as blockman doesn't seem to support alpha/opacity in color definition. I also might need to file a PR or two against blockman to fix small issues that prevent it from matching vscode-frame-rainbow's UX perfectly (most noticeably, "blockman.n16EnableFocus": false, appears not to take effect when combined with custom coloring rule from blockman.n33.

As a result of the above discovery, I'm considering deprecating vscode-frame-rainbow...

wizzard0 commented 1 year ago

Umm... actually after filing this issue I discovered Blockman as well, and yes it is kind of a superset of all other highlighters, and I'm going to play with it for a while but!

Guess I need to peek at both extensions' source and see what we can do about it %)