Skip to content

The line following a let in a do block should not be indented. #85

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

Closed
w9 opened this issue Oct 31, 2016 · 5 comments
Closed

The line following a let in a do block should not be indented. #85

w9 opened this issue Oct 31, 2016 · 5 comments

Comments

@w9
Copy link

w9 commented Oct 31, 2016

Right now after a complete let statement in a do block, a level of indentation is added for the next line:

main :: IO ()
main = do
    let a = 1
        █

This is not expected as let statements in do blocks don't need in clauses.

If this is in case the programmer wants to type in more than one assignments in a single let, then it is unexpected that re-indentation of the following block (using the = key):

main :: IO ()
main = do
    let a = 1
    return ()

gives me a wrong indentation that doesn't even compile:

main :: IO ()
main = do
    let a = 1
        return ()
@raichoo
Copy link
Member

raichoo commented Nov 1, 2016

While this is true there is not easy way to detect that you are in a do block other than doing backtracking which is rather expensive. Doing that with current Vim tools is not really feasible.

@danielwaterworth
Copy link

What's really annoying is that the indentation is often changed in cases like this where it was correct before. Is there a way to disable automatic indentation in this plugin? It makes it essentially unusable.

@raichoo
Copy link
Member

raichoo commented Nov 29, 2016

I've just merged #88 which introduces a flag to disable indentation, so you can use one that suits your style better.

@raichoo raichoo closed this as completed Nov 29, 2016
@danielwaterworth
Copy link

Great, thanks!

jez added a commit to jez/haskell-vim that referenced this issue Jul 14, 2017
This addresses some of the grievances in neovimhaskell#85. Namely, we give users the
option to change how indentation works with `let` statements.

Current behavior:

    -- g:haskell_indent_let
    let x = 0
    >>>>y = 0

    let x = 0 in
    >>>>x

    -- g:haskell_indent_in
    let x = 0
    >in x

    -- ??? (conflated with g:haskell_indent_let)
    let x = 0
    >>>>x

New behavior:

    -- g:haskell_indent_no_in
    let x = 0
    >>>>x

So for example, those who omit the 'in' on the first line and any 'let'
on the second line can opt to have no indentaton:

    --- g:haskell_indent_no_in = 0
    let x = 0
    fooBar x
@jez
Copy link
Contributor

jez commented Jul 19, 2017

You can actually get rid of this auto-indenting behavior (on latest master), with this new config setting:

let g:haskell_indent_let_no_in = 0

(See PR #98.)

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

4 participants