gleam-lang / tree-sitter-gleam

🌳 A tree-sitter grammar for the Gleam programming language
Apache License 2.0
66 stars 13 forks source link

Implement indents.scm file #86

Closed michaeljones closed 3 months ago

michaeljones commented 3 months ago

I am not very experienced with tree sitter at all. I am currently having this experience in the Helix editor:

fn render_home(request: Request) -> Response {<-- pressing enter here
  let body = element.to_string_builder(layout.login())
  wisp.html_response(body, 200)
}
fn render_home(request: Request) -> Response {
<-- leaves the cursor here with no indentation
  let body = element.to_string_builder(layout.login())
  wisp.html_response(body, 200)
}

Which feels a bit off when you're used to it indention properly in other languages.

I copied the indents.scm file from zed into my ~/.config/helix/runtime/queries/gleam folder and it seems to behave better in this case. I don't know if they are right or not or how complex this file could get but it seems to help me a bit. I've only just done it so I'm not sure if there are negative impacts that I've not experienced yet.

Edit: I should add that I appreciate others know far more about this than I do and there might be good reasons why we don't have an idents file defined.

the-mikedavis commented 3 months ago

This discussion might fit better in the Helix issues/discussions - each editor currently has its own indentation system so the queries aren't necessarily portable between them

michaeljones commented 3 months ago

Good to know. Thanks. I'll create a discussion item when I have a moment.