Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter not using styler? #675

Open
half-adder opened this issue Aug 14, 2024 · 0 comments
Open

Formatter not using styler? #675

half-adder opened this issue Aug 14, 2024 · 0 comments

Comments

@half-adder
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant