Closed alaindanet closed 10 months ago
I never used targets
. Indeed, this is the first time that I know about it. What specifically do you need? Sending code from (Neo)Vim from {targets
chunks to R? Syntax highlight of {targets
chunks? The pattern to recognize chunks of R code in Rmd files is hardcoded in Nvim-R/ftplugin/rmd_nvimr.vim
, Nvim-R/R/start_r.vim
, R-Vim-runtime/syntax/rmd.vim
, and R-Vim-runtime/indent/rmd.vim
. We could create a variable to replace "r" with whatever the user wanted, in this case, "r\|targets", but I don't know if this would be enough, and, since I'm not going to use targets
it would be better if someone else wrote a pull request for this.
Thank you so much for your answer. I have tried to spot the places where the changes could be made after you pointed the files:
In Nvim-R/ftplugin/rmd_nvimr.vim
:
r
to (r|targets)
?
function! RmdIsInRCode(vrb)
let chunkline = search("^[ \t]*```[ ]*{r", "bncW")
\\(r\\
to \\(r\\|targets\\
: let i = search("^[ \t]*```[ ]*{\\(r\\|python\\)", "bnW")
Change r"
to (r|targets)"
let chunkline = search("^[ \t]*```[ ]*{r", "bncW") + 1
Nvim-R/R/start_r.vim
:Change \\(r\\
to \\(r\\|targets\\
:
\ ((&filetype == "rmd" || &filetype == "quarto") && line =~ "^[ \t]*```{\\(r\\|python\\)"))
Change to (r|targets)
:
let begchk = "^[ \t]*```[ ]*{r"
In R-Vim-runtime/indent/rmd.vim
, change {r
to {(r|targets)
:
if getline(".") =~ '^[ \t]*```{r .*}$' || getline(".") =~ '^[ \t]*```$'
return 0
endif
if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW")
I did not find anything in R-Vim-runtime/syntax/rmd.vim
If you think that those changes are the ones to implement, I will give a try!
Yes, please try it. I suggest that you create a variable, perhaps named R_chunk_pattern
in your init.vim
:
R_chunk_pattern = 'r\|targets'
And, then, replace as in the example:
let i = search("^[ \t]*```[ ]*{\\(" . R_chunk_pattern . "\\|python\\)", "bnW")
I suggest creating a variable because we don't know if another pattern in the future will have to be recognized as an indicator of an R chunk.
Nvim-R
does not recognizetargets
chunk as code block containingR
code inRmd
files.targets
chunks contains R code that is managed by thetargets
R package to build a analysis pipeline.Is there an option to set
Nvim-R
to behave withtargets
chunk asr
chunk (i.e. sending code lines to the terminal, etc...) ?Currently the plugin returns
Not inside an R chunk.
when I try to send lines insidetargets
chunks.