15

For example, vim will not indent correctly the following code:

flights <- flights %>%
    group_by(year, month, day) %>%
    select(arr_delay, dep_delay) %>%
    summarise(
        arr = mean(arr_delay, na.rm = TRUE),
        dep = mean(dep_delay, na.rm = TRUE)
    ) %>%
    filter(arr > 30 | dep > 30)

Is there a way to fix this?

I'm using the Vim-R-Plugin, the related issue is here.

sudo bangbang
  • 27,127
  • 11
  • 75
  • 77
enricoferrero
  • 2,249
  • 1
  • 23
  • 28

1 Answers1

3

One thing you can do is learn vimscript and modify this behavior yourself. If it works well, you can contribute the change to the original author.

I started out this way but ended up writing my own indent code from scratch that does everything just the way I like it. I talked with the R plugin author about replacing his code with mine but my code has a couple of bugs I've never taken the time to find and that don't bother me much (it gets stuck if you have an unmatched close curly bracket, for example). I never got the motivation to clean it up the rest of the way and try and get it into the VIM repository.

In response to your query, I have put my code on github. You can try using my indent code instead of the r-plugin code if you want. It may or may not solve your issue (no promises). If I get motivated enough I may fix it up enough that we could make it the default vim indent code.

farnsy
  • 2,282
  • 19
  • 22