languageserver
languageserver copied to clipboard
Formatter not using styler?
I might have something wrong with my config but I can't figure out what. I am using vscode with the R extension using the languageserver. R is configured correctly (I think) such that I can run scripts, view plots, etc. Linting works as well.
Formatting does not seem to run through the styler package as expected.
Here is a file before formatting:
library("tidyverse")
tibble(x = 1:12, y = rnorm(12)) %>%
ggplot(aes(x = x, y = y)) +
geom_point() +
geom_smooth(method = "lm")
c(1,2,3)
And after formatting using the languageserver functionality in vscode (Right click > Format Document):
library("tidyverse")
tibble(x = 1:12, y = rnorm(12)) %>%
ggplot(aes(x = x, y = y)) +
geom_point() +
geom_smooth(method = "lm")
c(1, 2, 3)
As you can see, the lack of spaces in the last line is fixed. However, the indentation is using 4 spaces, not 2 spaces. The linter yells at me because of the wrong number of spaces.
If I use styler directly on the file (i.e. by opening an R terminal, and running the command style_file("/path/to/file.R")), I get the following:
library("tidyverse")
tibble(x = 1:12, y = rnorm(12)) %>%
ggplot(aes(x = x, y = y)) +
geom_point() +
geom_smooth(method = "lm")
c(1, 2, 3)
In this case, the indentation is correct.
Any advice?