r-lib / prettycode

Syntax highlight R code in the terminal
https://r-lib.github.io/prettycode/
Other
101 stars 9 forks source link

color brackets by scope #8

Closed mdequeljoe closed 5 years ago

mdequeljoe commented 5 years ago

This pr proposes the addition of colored brackets in order to help distinguish between scopes.

This is done by adding the entry: bracket to default_style whereby one can set the list of colouring functions to be used to color brackets.

An internal function color_brackets is added such that brackets are colored consecutively by the scope level according to the color sequence passed in via bracket. The following brackets are considered:

[[ [ ] ( ) { }

Note that the counterpart of [[ is two ] characters instead of ]] as this bracket would be parsed as an 'LBB' token (or as a 'SYMBOL_FUNCTION_CALL' and thus not passed on to color_brackets) Some more details are provided in the documentation.

gaborcsardi commented 5 years ago

Love this! I am in the middle of something, but will look at it later today. Thanks much!

codecov-io commented 5 years ago

Codecov Report

Merging #8 into master will increase coverage by 3.5%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master       #8     +/-   ##
=========================================
+ Coverage   83.47%   86.98%   +3.5%     
=========================================
  Files           5        6      +1     
  Lines         115      146     +31     
=========================================
+ Hits           96      127     +31     
  Misses         19       19
Impacted Files Coverage Δ
R/highlight.R 100% <100%> (ø) :arrow_up:
R/brackets.R 100% <100%> (ø)
R/style.R 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e0e04fe...dcdca0c. Read the comment docs.

gaborcsardi commented 5 years ago

Sorry, it took "a bit" longer in the end. :( I think this is great! Can you please add a bullet point to the NEWS, with your GH username and the PR id? Then I'll be most happy to merge it.

Thanks again!

gaborcsardi commented 5 years ago

You know what, don't worry about it, I'll do it....

Thanks again!

gaborcsardi commented 5 years ago

How could I live without this? I love this feature already.

mdequeljoe commented 5 years ago

great thanks!!