Closed aavogt closed 1 year ago
Could you please post an example of code that will be better highlighted if your pull request is merged?
c('data/b/c', 'data/b2/c') %>%
strsplit('/') %>%
map_chr( `[`(2) )
The problem is with .Rmd, not .R. I'm not sure what color the [ should be -- probably it should be the same as %>%
. Anyways, the ) is what's annoying me, but fixing the [ might fix the ) too.
The previous code marked the final ]
in xs[[ length(xs) ]]
as an error.
The syntax/r.vim has some lines that are not evaluated if the filetype is rmd:
https://github.com/jalvesaq/R-Vim-runtime/blob/master/syntax/r.vim#L235-L239
and
https://github.com/jalvesaq/R-Vim-runtime/blob/master/syntax/r.vim#L311-L313
Could you, please, try removing the condition? That is, syntax/r.vim would be exactly the same for both r and rmd. I know that this will fix the issue, but does it create new problems? We have to try the changes for some time to be sure.
I've settled on just adding
syn match rFunction "`\[\+`"
With .Rmd it looks like:
But with .R
, the https://github.com/jalvesaq/R-Vim-runtime/blob/master/syntax/r.vim#L311-L313 interferes, leading to:
We can't have https://github.com/jalvesaq/R-Vim-runtime/blob/a9b6ac04a9aea0a369f5e52a9475c71e4ad6adf4/syntax/r.vim#L311-L313 enabled in .Rmd because code blocks start with ```, which matches that pattern. That leads to no highlighting at all.
Changing the pattern to exclude ```{ :
syn region rNameWSpace start="`\(``{\)\@!" end="`" contains=rSpaceFun
makes Rmd highlighting look like .R
with
syn match rOperator "[|!<>^~`/:]"
And slightly better:
except with
syn match rOperator "[|!<>^~/:]"
Though perhaps the ``` be treated as before (brown/gold). But I can't figure that out. The best I can do is:
with
syn match rOperator "```"
It is preferable if the vim script to highlight R code is exactly the same in .R and .Rmd files. So, could you check the branch rmd_backtick, please? I deleted the "rmd" condition from syntax/r.vim and the chunk highlighting is still normal to me, as you can see in the image below:
Sorry for taking so long to look at this carefully.
Code like this doesn't need a matching
]
:My change won't warn about this:
But I think nobody puts
[
at the start of the line.