gleam-lang / gleam-mode

🐙 Gleam support for Emacs
Apache License 2.0
80 stars 23 forks source link

gleam-ts-mode: Auto-indentation when pressing RET in the presence of incomplete Nodes #34

Open frou opened 2 months ago

frou commented 2 months ago

e.g. when typing a function signature and pressing RET after the opening {, should the new line be automatically indented by an additional 2 spaces?

I see that the gleam-ts-mode.el file has a good amount of stuff related to indentation, but I'm not sure if such auto-indentation on RET is supposed to work yet. It doesn't for me.

J3RN commented 2 months ago

I'd say that ideally it should work. The rules get a bit odd because when starting e.g. a new function, there's not an concrete syntax tree (CST) node there that we can attach indentation rules to. I thought we had worked around this with a rule like "anything after the braces is indented" but I'll need to check again.

frou commented 2 months ago

Thank you, that explanation makes a lot of sense.

abueide commented 2 weeks ago

@J3RN should indentation work when creating a newline inside of a pub type Blah {} brace? Seems to not work in those, only in functions

J3RN commented 1 week ago

Obviously I'm a bit strapped for time lately, but if someone wants to investigate these issues, you can play with the indentations rules. Happily they're quite declarative, though the selectors (e.g. parent-bol) are a bit arbitrarily defined.