I would like code and markup inside certain tags to be indented. Currently, this occurs…
<style> body { … } </style>
Desired result:
<style> body { … } </style>
I’ve determined that this is because style, script, and other tags are marked as `source.*`. If I rename these language constructs to something that doesn’t start with “source”, then indentation works as expected. However, I do not want to throwaway the advantages of inheriting from source.
Does anyone know where I can begin looking to modify the `source` grammar so that code within certain tags is indented? I have not had any luck with `increaseIndentPattern` (yet).
Formatting did not transfer. In the second example, I’d like the `body` tag indented by two spaces.
On Sep 24, 2014, at 4:36 PM, David Aaron Fendley tricon@me.com wrote:
I would like code and markup inside certain tags to be indented. Currently, this occurs…
<style> body { … } </style>
Desired result:
<style> body { … } </style>
I’ve determined that this is because style, script, and other tags are marked as `source.*`. If I rename these language constructs to something that doesn’t start with “source”, then indentation works as expected. However, I do not want to throwaway the advantages of inheriting from source.
Does anyone know where I can begin looking to modify the `source` grammar so that code within certain tags is indented? I have not had any luck with `increaseIndentPattern` (yet).
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 25 Sep 2014, at 1:36, David Aaron Fendley wrote:
I would like code and markup inside certain tags to be indented […] I’ve determined that this is because style, script, and other tags are marked as `source.*` […]
Does anyone know where I can begin looking to modify the `source` grammar so that code within certain tags is indented? I have not had any luck with `increaseIndentPattern` (yet).
Your assertion is correct, with the new ability to see active settings it’s actually not that difficult to debug what goes on.
Open a new HTML document and then ⌃⌘T (Bundles → Select Bundle Item…). Switch to Settings (⌘}) and type ‘increaseindent’. You’ll see there is just one item matching here, the one from the HTML bundle. You can select Edit to inspect its scope selector (text.html).
Now type <style> and again bring up the settings inspector (I realize now it should be “live”). Now there are two items matching, with the new one from the Source bundle eclipsing our HTML bundle’s settings item.
This is because the scope is now “text.html source” (which you can see with ⌃⇧P) and the source bundle’s settings are scoped to “source”, which in this case is more specific (deeper), so it wins.
To make the HTML setting the one that wins, we can change it’s scope selector to: text.html, text.html source
However, if we change <style> to <script> then indent misbehaves again. Looking in our settings list we can see that the JaveScript bundle’s setting is now the one taking precedence, that’s because it is targeting ‘source.js’ which is more specific than just ‘source’, so we must change the HTML item’s scope selector to: text.html, text.html source, text.html source.js
I hope the above makes sense.