Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with Emmet #40

Open
kblais opened this issue Nov 28, 2024 · 2 comments
Open

Conflict with Emmet #40

kblais opened this issue Nov 28, 2024 · 2 comments

Comments

@kblais
Copy link

kblais commented Nov 28, 2024

Description of the bug

Hi,
Since the last version (4.0, received today), I can't use Emmet expanding through the tab key anymore.
Pressing tab creates a basic tab character.

Steps to reproduce

  1. Install Emmet and Twig syntax packages, with default configuration
  2. Create a new Twig file with Html (Twig) syntax
  3. Type an emmet compatible syntax, for example ul>li*3
  4. Press tab

Expected behavior

ul>li*3 should be converted to HTML code

Actual behavior

A tabulation is added to the code

Twig version

4.0.0

@deathaxe
Copy link
Contributor

deathaxe commented Dec 3, 2024

The issue is caused by Emmet's "abbreviation_scopes" selectors, which exclude all sorts of meta. scopes.

{
		"abbreviation_scopes": [
			"(text.html | text.xml) - source - meta - comment",
			...
		],
}

Twig as well as other HTML based template syntaxes started to scope content text.html.<name> meta.template to indicate their template character and enable snippets/completions accross all supported (sub-)syntax definitions (e.g. CSS, JS, JSON, ...) with same set of selectors.

Recommendation is to adjust "abbreviation_scopes" to only exclude tags (meta.tag) and embedded template code tags/blocks (meta.embedded) as well as string interpolation (meta.interpolation).

{
		"abbreviation_scopes": [
			"(text.html | text.xml) - source - meta.tag - meta.embedded - meta.interpolation - comment",
			...
		],
}

I'd even recommend to make them a bit more restrictive to also properly handle scenarios in which html/xml is embedded into other languages such as Markdown (fenced code blocks).

{
		"abbreviation_scopes": [
			"text.html - text.html source - text.html meta.tag - text.html meta.embedded - text.html meta.interpolation - text.html comment",
			"text.xml - text.xml source - text.xml meta.tag - text.xml meta.embedded - text.xml meta.interpolation - text.xml comment",
			...
		],
}

deathaxe added a commit to deathaxe/Emmet that referenced this issue Dec 9, 2024
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`.

related with Sublime-Instincts/BetterTwig#40
deathaxe added a commit to deathaxe/Emmet that referenced this issue Dec 9, 2024
Fixes emmetio#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`.
sergeche pushed a commit to emmetio/sublime-text-plugin that referenced this issue Dec 9, 2024
* 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`.
@deathaxe
Copy link
Contributor

Fixed by Emmet.

Can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants