Skip to content

[Bug]: indentation clash (formatter vs lintr) #1883

Open

Description

@grantmcdermott

Area

Syntax highlighting

Bug description

VS Code indents with 4 spaces by default, and vscode-R doesn't override this for R. However, lintr expects indentation of 2 spaces. This leads to a harmless, but annoying linting markup for any new R file:

Image

Steps to reproduce

Open a new file and type and write some code with indentation, e.g. a function call over multiple lines:

plot(
    1:10
)

Again, the 4 spaces is what gets produced automatically. But lintr will complain that it should only be 2.

 [indentation_linter] Indentation should be 2 spaces but is 4 spaces.

Expected behavior

The indentation behaviour or vscode-R should accord with its default linter. My own preference is for that to be 2 spaces, which is the standard that most R linters follow (incl. lintr, air, etc.)

We could set this part of the r block in configurationDefaults.

"[r]": {
    "editor.tabSize": 2
  }

Environment

vscode-R: 3.2.0
R: 4.6.1

Relevant R package versions

packageVersion('lintr')
[1] ‘3.4.0’

Relevant VS Code settings

Logs and additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions