Skip to content

Comments aren't taken into account when determining indent level #1473

@ntc2

Description

@ntc2

(Originally reported against Intero here. All occurrences of "Intero" below mean "haskell-mode").

For example:

foo x = y
  where
  -- Let me tell you about @y@!
    <-- Only TAB stop on this line is two spaces in from "where".

I would like to be able to indent the next line to the same level as the beginning of the comment.

On the other hand, Intero does take non-comment lines into account when determining indent level, so the following is handled correctly:

foo x = z
  where
  y = x
  <-- Here I can TAB to the same indent level as "y".

Probably related: immediately after a where, Intero only supports indenting one level past the where, not indenting to the same level as the where. I thought of this as "Intero has an opinion about how to best indent my code", which is usually fine, since I can usually override Intero by manually indenting the first line (More important, common case: I'm editing an existing code base that aligns the where-clauses to the same level as the where keyword, and of course I don't want to indent all of them just to make Intero happy).

So, a simple fix might be to soften Intero's opinion of best indentation style: make the first TAB stop one more level in (or whatever Intero's opinion is), but make the "aligned with where" choice always be available as the second TAB stop.

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