Hello,
I am writing a Svelte language pack for codemirror and I am trying to understand how does the auto indentation work.
I am aware that I can configure the indentation behaviour with indentNodeProp.add(...) method, this works as expected. Yet, I found that even if I don’t add any configuration, CodeMirror still able to auto indent HTML-like tags (e.g. {#if} block in Svelte). I dig around and found that this might be related to the openedBy and closedBy prop for the node. According to the docs:
CodeMirror Language Pack Example:
The information added by
@detectDelimwould already allow the automatic indentation to do a reasonable job
Lezer Docs:
If you put a
@detectDelimdirective at the top level of your grammar file, the parser generator will automatically detect rule delimiter tokens, and createopenedByandclosedByprops for rules where it finds them.
I suspect that as I have used openedBy and closedBy prop for my nodes in the grammar file (I did not use @detectDelim) CodeMirror is able to do the auto indentation for HTML-like tags. I would like to know if this is the case, if yes, what is the expected behaviour (i.e. when exactly will it do the indentation automatically without configuration)?
Any links to the docs that will be helpful are also appreciated. Thanks.