Skip to content

Indention dependent on token-length #66

Closed

Description

@lorenzwalthert

styer indents two spaces for each level:

call(
  call(
    call(3
    )
  )
)

However, we generally don't want two spaces. If the first argument of the indenting call follows on the same line, we want to indent depending on the length of the indenting token (at least RStudio does that):

very_long_call_here(1  
                    second_argument,
                    third_argument
)

Activity

  1. lorenzwalthert commented on Jul 5, 2017

    @lorenzwalthert
    CollaboratorAuthor

    The illustrative example above is actual a special case for which it is easy to get the correct indention, since we simply have to check the token length of very_long_call_here (and add two spaces) and we are there. However, the real challenge is to get something like the following right:

    a <- call(2,
              2
    )

    Here, we essentially have to know where the token call starts, not just how long it is. We only need to know the position of the token relative to the indention though, which is different from #65, where we probably need to know the absolute position of the token.

  2. krlmlr commented on Jul 5, 2017

    @krlmlr
    Member

    This is relevant for function() declarations in the tidyverse style guide.

  3. lorenzwalthert commented on Jul 30, 2017

    @lorenzwalthert
    CollaboratorAuthor

    Similar to #94

  4. lorenzwalthert commented on Jul 31, 2017

    @lorenzwalthert
    CollaboratorAuthor

    Agree that for the tidyverse style guide, only function declarations are relevant. However, I think it is preferable to also implement it for function calls and then add a rule that adds a line break after the opening round brace so we can leave it to the style guide in use whether or not to also indent token-dependent for function calls.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions