When using haskell-mode
(the Haskell layer) with evil-mode
keybindings in spacemacs, the indentation created by pressing the o key is often incorrect.
For instance, imagine I want to write the following Haskell file:
module Foo where
foo :: Int
foo = 3
However, I've only written the following. I haven't yet created the function body for the foo
function:
module Foo where
foo :: Int
If I am in insert mode and have my cursor after the "t" in Int
and press Enter, the cursor goes to the next line in the first column, directly under the "f" in "foo". Using an underscore (_
) for the cursor position, it looks like this:
module Foo where
foo :: Int
_
This is correct.
However, if I am in normal mode and have my cursor anywhere in the line with "foo" and press o, the cursor goes to then next line in the third column. It looks like this:
module Foo where
foo :: Int
_
This is incorrect. I have to press Backspace twice to put the cursor in the first column before I can start writing the definition of foo
.
It seems like indentation rules are getting messed up. Why is the indentation different depending on whether Enter is pressed in insert mode, or o is pressed in normal mode?
How can I get o to indent the same as Enter in insert mode?
Here is my current .spacemacs
config file. To my knowledge, I don't have any settings set that effect indentation.
edit: Just so my intentions are clear, I do want indentation to be happening when I press either Enter or o. But I want it to be the appropriate indentation. Currently, pressing o results in incorrect indentation.
o
key inserts a newline and reindents, so the reason yourEnter
key doesn't behave the same way is either because you've disabled auto-indent or Spacemacs does weird things. I'm personally leaning towards the latter. Repro this without Spacemacs, then we'll talk.Enter
ando
keys, and seeing what commands are being run? In Spacemacs that would beSPC h k Enter
andSPC h k o
. You can then modifyo
so that it runs the same function asEnter
. I don't know why you wouldn't want your code indented, though.foo
is not appropriate. I've updated the question to make this more clear.