Magento 2 Snippets for Zed

March 31, 2026 · View on GitHub

Zed

Magento 2 and Hyvä snippets for the Zed editor.

Covers the boilerplate you write every day, from phtml headers and CSP script tags to layout XML, di.xml, and system.xml.

Installation

Via Zed Extensions

  1. Open Zed and go to the Extensions panel (cmd+shift+x).
  2. Search for "Magento 2 Snippets" and click "Install".

Via Developer install

Requires rustup (Rust must be installed via rustup specifically, not Homebrew or other package managers).

  1. Clone this repository to your local machine.
  2. Open Zed and go to the Extensions panel (cmd+shift+x).
  3. Click "Install Dev Extension" at the top of the panel.
  4. Select the folder where you cloned this repository.

Zed will load the extension directly from that folder. Any changes you make to the snippet files are picked up after reloading the extension from the Extensions panel.

To show snippets at the top of the autocomplete list, add this to your Zed settings:

{
    "snippet_sort_order": "top"
}

This can also be scoped per language if you only want it for PHP and XML:

{
    "languages": {
        "PHP": { "snippet_sort_order": "top" },
        "XML": { "snippet_sort_order": "top" }
    }
}

Complementary extensions

This extension focuses on Magento 2 and Hyvä specific snippets.

For generic PHP and Alpine.js snippets useful in day to day development, install these extensions alongside it:

Available Snippets

PHP

Magento
PrefixDescription
escapeHtml.magentoEscape a string for safe HTML output
escapeUrl.magentoEscape a string for safe use in URLs
escapeHtmlAttr.magentoEscape a string for safe use in HTML attributes
escapeJs.magentoEscape a string for safe inline JavaScript output
__.magentoWrap a string in Magento's translation function
getUrl.magentoGenerate a store URL from a route path
getChildHtml.magentoRender a child block by name
getData.magentoGet a data value from the current block
header.magentoStandard phtml file header
registration.magentoModule registration.php
script.magentoInline script block using SecureHtmlRenderer
style.magentoInline style tag using SecureHtmlRenderer
argumentClass.magentoBase class implementing ArgumentInterface
Hyvä
PrefixDescription
header.hyvaStandard phtml file header with Hyvä imports
icon.hyvaRender a custom SVG icon via the svgicons ViewModel
lucideIcon.hyvaRender a Lucide SVG icon via the lucideIcons ViewModel
viewModel.hyvaRequire a ViewModel from the ViewModelRegistry
dispatchMessage.hyva.jsShow a UI message via dispatchMessages
privateContent.hyva.jsListen for the private-content-loaded event
reloadCustomerSection.hyva.jsDispatch reload-customer-section-data event
formatPrice.hyva.jsFormat a number as a store price string
script.hyvaCSP inline script block with Alpine component

XML

Layout
PrefixDescription
page.layout.magentoBase page layout XML structure
block.layout.magentoDeclare a block with class, name and template
container.layout.magentoDeclare a layout container
referenceBlock.layout.magentoReference an existing block
referenceContainer.layout.magentoReference an existing container
move.layout.magentoMove a block or container
remove.layout.magentoRemove an existing block
update.layout.magentoInclude another layout handle
arg.layout.magentoPass a string argument to a block
argBool.layout.magentoPass a boolean argument to a block
argArray.layout.magentoPass an array argument to a block
item.layout.magentoA single item inside an array argument
viewModel.layout.magentoInject a ViewModel into a block
css.layout.magentoInclude a CSS file from a module
js.layout.magentoInclude a JS file from a module
font.layout.magentoPreload a font file from a module
System (system.xml)
PrefixDescription
config.system.magentoRoot system.xml config wrapper
tab.system.magentoDeclare a system config tab
section.system.magentoDeclare a system config section
group.system.magentoDeclare a system config group
field.system.magentoDeclare a system config field
depends.system.magentoAdd a depends block to a field
Dependency Injection (di.xml)
PrefixDescription
config.di.magentoRoot di.xml config wrapper
type.di.magentoDeclare a type for plugins or arguments
plugin.di.magentoDeclare a plugin for a type
preference.di.magentoOverride a class with a preference
virtualType.di.magentoDeclare a virtual type
Module (module.xml)
PrefixDescription
config.module.magentoRoot module.xml with module declaration and sequence

LESS

Magento
PrefixDescription
@mq.mobile.magentoMagento LESS media query for mobile styles
@mq.desktop.magentoMagento LESS media query for desktop styles

Contributing

Contributions are welcome. For larger changes, open an issue first to discuss what you have in mind.

  1. Fork the repository.
  2. Clone your fork.
  3. Make your changes.
  4. Test in Zed using the developer install steps.
  5. Submit a pull request.

License

Copyright © 2026 GrimLink. Released under the MIT License.