[TxMt] Re: Indenting Code & Markup Within Source Tags
Allan Odgaard
mailinglist at textmate.org
Thu Oct 2 20:46:35 UTC 2014
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.
More information about the textmate
mailing list