reddit / emacs

Help with indentation in haskell

patrickaldis · 2022-11-06 10:18
I'm trying to switch from vscode, but I'm having a few problems with indentation. The smart indent doesn't seem to recognise the correct number of spaces. https://reddit.com/link/ynmdap/video/pz2uwvgv1by91/player Is this the correct behaviour for haskell files? Thanks for any help :)
pwnedary · 2022-11-06 12:35
Instead of `o` type `A<RET>` to continue on the next line, when in Evil Normal mode. That way it runs the haskell-mode `newline-and-indent` function which is "more contextual" instead of opening a new line and then attempting to indent that new line universally. I guess you could override `o` to do just that when editing Haskell files. And as you likely already know, you can hit `<Tab>` to cycle between possible indentation levels.
patrickaldis · 2022-11-06 12:48
Thanks so much! Didn't realise evil indented differently. That's a bit of a pain
SasukeUchiha231 · 2022-11-06 13:48
you have to set evil-auto-indent t, for evil to auto indent. (setq evil-auto-indent t)
pwnedary · 2022-11-06 14:27
That variable defaults to `t`.
yordanm · 2022-11-06 15:55
Stop being evil.
fatfingerdeathcrunch · 2022-11-06 16:51
Evil is doing indentation, but based on a strange variable. Can‘t look it up right now. Check the function bound to `o` with `C-h-k o` maybe it is already in its doc.
fatfingerdeathcrunch · 2022-11-06 17:30
Ah sorry, mixed that up. It was a different case for me. I had to set \`sh-basic-offset\`. In your case, evil is calling \`evil-open-below\` which is calling \`indent-according-to-mode\`: >Indent line in proper way for current major mode. Normally, this is done by calling the function specified by the variable \`indent-line-function'. However, if the value of that variable is present in the \`indent-line-ignored-functions' variable, handle it specially (since those functions are used for tabbing); in that case, indent by aligning to the previous non-blank line.