R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
128 stars 15 forks source link

Error when sending code to the console when there are roxygen2-type comments #106

Open typhooncamel opened 3 months ago

typhooncamel commented 3 months ago

If there are roxygen2-type comments (preceded by #') and these are part of a selection being sent to the R console, there will be an error. E.g., if you have

MyFunction = function(x)
{
  print(x)
}

#' Another function.

AnotherFunction = function(x)
{
  print(x)
}

and you visually select the two functions and send to the R session, I get Error: unexpected symbol in " Another function.".

PMassicotte commented 3 months ago

Looks like the issue is there:

https://github.com/R-nvim/R.nvim/blob/cb65c3b288d22212e248d2cb8bf3ca46baa7201c/lua/r/cursor.lua#L23

jalvesaq commented 3 months ago

This is a feature, not a bug. Someone in the past asked for this. The goal is to be able to send sample code from the ROxygen comment area, but any change in this behavior will be good for me. We can remove the feature, create an option to disable it, or leave it as is.

typhooncamel commented 3 months ago

Ok, good to know. I'm happy either way, at least knowing that's the expected behaviour. I'd say it's a bit odd (because it prevents you from doing precisely what I was doing, sending whole blocks). Testing code in the ROxygen comment area seems somewhat niche. However, I'm happy with whatever the consensus is.