Open flooose opened 2 years ago
For me the expectation would be that these lines are also indented and every indentation after is relative to this first indentation, like in this buffer that only has graphql-mode active (i.e. no polymode).
Is that the case? If I type your example and the first line query
has some indentation, the rest of the code indents absolutely and not relative to the first line still I think.
If you look at the graphql-indent-line
the indentation level is calculated as just the nesting level in the parens.
You could try to find the indentation level of the top-level line and add it as an offset to there.
Is that the case? If I type your example and the first line query has some indentation, the rest of the code indents absolutely and not relative to the first line still I think.
Ah, you're right
If you look at the
graphql-indent-line
I'll have a look and report back. Is this something you'd like as a pull request?
I'll have a look and report back. Is this something you'd like as a pull request?
It'd be great yes!
As long as top-level code is indented at level 0 by default, this seems like a nice extension to the current behavior. I don't see any downside with it 🙂 and looking at other modes, they all seem to behave this way as well.
I work a lot in with ruby, where our tests have a lot of graphql queries written in HEREDOCs. I've written the following polymode definition to allow graphql-mode nested in ruby-mode:
which allows me to write the following in ruby:
As you can see the indentation works for all but the first and the last lines. For me the expectation would be that these lines are also indented and every indentation after is relative to this first indentation, like in this buffer that only has graphql-mode active (i.e. no polymode).
I was able to reproduce the error by defining a polymode for sh-mode, which also supports HEREDOCs
here's the result:
If this really is a graphql-mode issue, I'd be happy to take a look at the code, you just have to point me in the right direction.
Thank you in advance!