Skip to content

Commit

Permalink
Tweak HTML/XML related selectors in settings (#189)
Browse files Browse the repository at this point in the history
* Fix settings indentation

This commit common indentation style to all settings.

According to .editorconfig `tabs` seem preferred indentation.

* Fix html syntax scope

Fixes #188

Ensure to detect embedded HTML code, but exclude embedded source in HTML.

This commit enables Emmet in e.g. Astro templates of scope:
`source.astro text.html.astro`.

It however disables it within embedded sources of scope `text.html source`.

related with SublimeText/Astro#10

* Fix HTML/XML abbreviation scopes

Fixes #184
Fixes Sublime-Instincts/BetterTwig#40

This commit fixes abbreviations being disabled in various template syntaxes
such as Jinja2 or Twig, which use common `text.html meta.template` scope to
enable template related snippets and completions in all sub-syntaxes with
easy/short selectors.

Instead of excluding all meta scopes by `- meta`, only relevant ones are,
which indicate embedded or interpolated templating code or html tags.

`text.html.cfml - meta.tag` is removed as it is coverd by
`text.html - text.html meta.tag`.

Note each negative selector is prefixed with `text.html` to make sure to match
only parts within HTML/XML, even if it is embedded in another source code.
That's required to keep abbreviations working in e.g. `source.astro text.html`.
  • Loading branch information
deathaxe authored Dec 9, 2024
1 parent 065d02e commit 76c045c
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions Emmet.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
// – true: enable preview for both markup and stylesheet abbreviations
// – false: completely disable preview
// – "markup" or "stylesheet": enable previews for either markup or stylesheet abbreviations
"abbreviation_preview": true,
"abbreviation_preview": true,

// If enabled, all abbreviations in JSX must be prefixed with `<` character.
// It allows you to explicitly specify that you are typing abbreviation and
// want to expand it with `Tab` key.
// Disabling this option will likely break native ST `Tab` key handler like
// inserting completions and indenting code
// New in 2.4.4: Set prefix value as string
"jsx_prefix": true,
// If enabled, all abbreviations in JSX must be prefixed with `<` character.
// It allows you to explicitly specify that you are typing abbreviation and
// want to expand it with `Tab` key.
// Disabling this option will likely break native ST `Tab` key handler like
// inserting completions and indenting code
// New in 2.4.4: Set prefix value as string
"jsx_prefix": true,

// Scope for marked abbreviation region highlighting
"marker_scope": "comment",

// Editor scope to Emmet syntax mapping
"syntax_scopes": {
"html": "text.html - source - meta.attribute-with-value.style",
"html": "text.html - text.html source - meta.attribute-with-value.style",
"xml": "text.xml - text.xml.xsl",
"xsl": "text.xml.xsl",
"jsx": "source.js.jsx | source.tsx | source.js | source.jsx",
Expand All @@ -53,12 +53,12 @@
// List of scope selectors where abbreviation marker should be activated,
// e.g. plugin will mark text that user types as abbreviation
"abbreviation_scopes": [
"(text.html | text.xml) - source - meta - comment",
"text.html - text.html meta.tag - text.html meta.embedded - text.html meta.interpolation - text.html comment - text.html source",
"text.xml - text.xml meta.tag - text.xml meta.embedded - text.xml meta.interpolation - text.xml comment - text.xml source",
"source.sass - meta.property-value - meta.property-name - string - punctuation - comment",
"(source.css | source.scss | source.less | source.postcss | source.stylus) & meta.property-list",
"(source.css | source.scss | source.less | source.postcss | source.stylus) - meta.property-value - meta.property-name - string - comment",
"(source.tsx | source.js | source.jsx) - comment",
"text.html.cfml - meta.tag",
"(source.tsx | source.js | source.jsx) - comment",
// Inline CSS
"text.html meta.attribute-with-value.style (string.quoted | source.css)"
],
Expand All @@ -69,15 +69,15 @@
"ignore_scopes": [],

// Expand Emmet abbreviation with Tab key when in abbreviation marker
"tab_expand": true,
"tab_expand": true,

// Expand Emmet abbreviation with Tab key with multiple cursors in editor.
// Currently, this mode is less restricted that single-cursor Tab: it doesn’t
// require abbreviation to be immediately typed and expanded by user, it may
// expand existing abbreviation.
// As a side-effect, you may not be able to insert tab character after words
// if this option is enabled
"multicursor_tab": true,
// Expand Emmet abbreviation with Tab key with multiple cursors in editor.
// Currently, this mode is less restricted that single-cursor Tab: it doesn’t
// require abbreviation to be immediately typed and expanded by user, it may
// expand existing abbreviation.
// As a side-effect, you may not be able to insert tab character after words
// if this option is enabled
"multicursor_tab": true,

// Emmet syntaxes (keys of "syntax_scopes" dictionary) where Tab expander
// is limited to known snippets only.
Expand All @@ -91,11 +91,11 @@
// * any predefined Emmet snippet
// * upper-cased word (JSX, Svelte components)
// * words with dash (Vue, Web Components)
"known_snippets_only": ["html"],
"known_snippets_only": ["html"],

// Automatically insert `class` attribute when typing `.` inside open tag
// and `id` attribute when typing `#`
"auto_id_class": false,
// Automatically insert `class` attribute when typing `.` inside open tag
// and `id` attribute when typing `#`
"auto_id_class": false,

// Display open tag preview next to closing tag when caret is inside it
// and open tag is not currently visible
Expand Down Expand Up @@ -174,14 +174,14 @@
// See `GlobalConfig` interface for supported properties: https://github.com/emmetio/emmet/blob/master/src/config.ts
// Example:
// "config": {
// "markup": {
// "snippets": {
// "foo": "foo.bar>baz"
// },
// "options": {
// "output.selfClosingStyle": "xhtml"
// }
// }
// "markup": {
// "snippets": {
// "foo": "foo.bar>baz"
// },
// "options": {
// "output.selfClosingStyle": "xhtml"
// }
// }
// }
"config": {},

Expand Down

0 comments on commit 76c045c

Please sign in to comment.