Skip to content

kaermorchen/vscode-drupal

Repository files navigation

VSCode Drupal

This extension supports only Drupal projects which use composer template drupal/recommended-project.

Features

  • syntax highlighting
  • hook completion
  • twig completion
  • service completion
  • global variables completion
  • code checking Drupal coding standards (phpcs, coder)
  • document formatting by standards (phpcbf)
  • searching in Drupal API Documentation
  • translation autocomplete (php, twig, js)
  • validation and autocomplete for YAML files

Experimental features

The experimental features turned off by default. But you can turn them on in the extension settings.

Install

Code checking and formatting require the following packages:

composer require --dev squizlabs/php_codesniffer drupal/coder

PHPStan analysis requires the following packages:

composer require --dev phpstan/phpstan phpstan/extension-installer phpstan/phpstan-deprecation-rules mglaman/phpstan-drupal

Package paths can be specified in the extension settings.

For YAML files, the YAML extension must be installed.

Demo

Hook completion

hook

Code checking and formatting

phpcs

Translation autocomplete

The extension parse *.po files inside a module direcory and autocomplete strings

PHP

t markup

Twig

twig

JavaScript

js

Drupal Search API

search

TODO

  • Autogeneration PO files
  • Twig local variable completion