Nvim-R icon indicating copy to clipboard operation
Nvim-R copied to clipboard

Long functions break the plugin

Open ttunguz opened this issue 3 years ago • 7 comments

I have a long function I use to format charts:

gg_format <- function() {
    color.background = "white"
    color.grid.major = "gray70"
    color.axis.text = "gray30"
    color.axis.title = "gray50"
    color.title = "gray30"
    theme_bw(base_size=24) +
        theme(panel.background=element_rect(fill=color.background, color=color.background)) +
        theme(plot.background=element_rect(fill=color.background, color=color.background)) +
        theme(panel.border=element_rect(color=color.background)) +
        theme(panel.grid.major.y=element_line(color=color.grid.major,size=.25)) +
        theme(panel.grid.major.x=element_line(color=color.grid.major,size=.25)) +
        theme(panel.grid.minor=element_blank()) +
        theme(axis.ticks=element_blank()) +
        theme(strip.background = element_blank())+
        theme(legend.position="bottom") +
        theme(legend.background = element_rect(fill=color.background)) +
        theme(legend.key = element_rect(colour = 'white')) +
        theme(legend.text = element_text(size=24,color=color.axis.title)) +
        theme(plot.title=element_text(color=color.title, size=24, vjust=1.25)) +
        theme(axis.text.x=element_text(size=24,color=color.axis.text, family="Roboto Mono")) +
        theme(axis.text.y=element_text(size=24,color=color.axis.text, family="Roboto Mono")) +
        theme(axis.title.x=element_text(size=24,color=color.axis.title, vjust=0, family="Roboto Mono")) +
        theme(axis.title.y=element_text(size=24,color=color.axis.title, vjust=1.25, family="Roboto Mono")) 
}

If I run the function through the plugin (I use F9), then I receive

Error: unexpected '}' in "}"

But I remove the trailing } and step through the function line by line (so the plugin doesn't ingest the entire function at once and then insert the } and then press f9 again, it works.

In other words I send

gg_format <- function() {
    color.background = "white"
    color.grid.major = "gray70"
    color.axis.text = "gray30"
    color.axis.title = "gray50"
    color.title = "gray30"
    theme_bw(base_size=24) +
        theme(panel.background=element_rect(fill=color.background, color=color.background)) +
        theme(plot.background=element_rect(fill=color.background, color=color.background)) +
        theme(panel.border=element_rect(color=color.background)) +
        theme(panel.grid.major.y=element_line(color=color.grid.major,size=.25)) +
        theme(panel.grid.major.x=element_line(color=color.grid.major,size=.25)) +
        theme(panel.grid.minor=element_blank()) +
        theme(axis.ticks=element_blank()) +
        theme(strip.background = element_blank())+
        theme(legend.position="bottom") +
        theme(legend.background = element_rect(fill=color.background)) +
        theme(legend.key = element_rect(colour = 'white')) +
        theme(legend.text = element_text(size=24,color=color.axis.title)) +
        theme(plot.title=element_text(color=color.title, size=24, vjust=1.25)) +
        theme(axis.text.x=element_text(size=24,color=color.axis.text, family="Roboto Mono")) +
        theme(axis.text.y=element_text(size=24,color=color.axis.text, family="Roboto Mono")) +
        theme(axis.title.x=element_text(size=24,color=color.axis.title, vjust=0, family="Roboto Mono")) +
        theme(axis.title.y=element_text(size=24,color=color.axis.title, vjust=1.25, family="Roboto Mono")) 

and then send

}

Thanks!

ttunguz avatar Jul 27 '22 15:07 ttunguz

I can't replicate the issue with R running in either Vim or Neovim built-in terminal on Linux (Ubuntu 22.04).

jalvesaq avatar Jul 28 '22 00:07 jalvesaq

I have this kind of issue regularly. I often have to visually select the whole function first and then send the lines, to make it work. macOS 12.4 with NVIM v0.7.2 Build type: Release LuaJIT 2.1.0-beta3

PhilippVWC avatar Jul 30 '22 11:07 PhilippVWC

I'm on a Mac too.

On Sat, Jul 30, 2022, 4:53 AM PhilippVWC @.***> wrote:

I have this kind of issue regularly. I often have to visually select the whole function first and then send the lines, to make it work. macOS 12.4 with NVIM v0.7.2 Build type: Release LuaJIT 2.1.0-beta3

— Reply to this email directly, view it on GitHub https://github.com/jalvesaq/Nvim-R/issues/683#issuecomment-1200144068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADP6ZRGKZQLWTJKVEWFBKTVWUJRXANCNFSM542DKM5A . You are receiving this because you authored the thread.Message ID: @.***>

ttunguz avatar Jul 30 '22 13:07 ttunguz

The function has 1510 characters. Perhaps, that's too much for pasting in your terminal. Could you try a different terminal emulator? Please, see also the option R_bracketed_paste.

jalvesaq avatar Oct 25 '22 11:10 jalvesaq

Thanks. I tried 4 different emulators: Terminal, Alacritty, Warp, & Kitty but they all failed.

On the R_bracketed_paste, does that require Radian? On 2022-10-25, elvis kahoro wrote:

The function has 1510 characters. Perhaps, that's too much for pasting in your terminal. Could you try a different terminal emulator? Please, see also the option R_bracketed_paste.

-- Reply to this email directly or view it on GitHub: https://github.com/jalvesaq/Nvim-R/issues/683#issuecomment-1290424244 You are receiving this because you authored the thread.

Message ID: @.***>

-- Tom Tunguz tomtunguz.com

ttunguz avatar Oct 27 '22 02:10 ttunguz

R_bracketed_paste doesn't require Radian. I use it with regular R in Gnome Terminal (but your code also is sent without problems when R_bracketed_paste=0). You could just put it in your vimrc/init.vim and see if it makes any difference:

let R_bracketed_paste = 1

jalvesaq avatar Oct 27 '22 02:10 jalvesaq

Thanks, I just gave that a try, but it doesn't work either. I appreciate the help.

On Wed, Oct 26, 2022 at 7:56 PM Jakson Alves de Aquino < @.***> wrote:

R_bracketed_paste doesn't require Radian. I use it with regular R in Gnome Terminal (but your code also is sent without problems when R_bracketed_paste=0). You could just put it in your vimrc/init.vim and see if it makes any difference:

let R_bracketed_paste = 1

— Reply to this email directly, view it on GitHub https://github.com/jalvesaq/Nvim-R/issues/683#issuecomment-1292900758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADP6ZQV64XV453HQWHWPL3WFHVNRANCNFSM542DKM5A . You are receiving this because you authored the thread.Message ID: @.***>

ttunguz avatar Oct 27 '22 03:10 ttunguz