localgovdrupal / localgov_project

Project template for Drupal 10 sites built with the LocalGov Drupal distribution.
https://localgovdrupal.org
GNU General Public License v2.0
11 stars 9 forks source link

Visual Studio Code workspace settings #110

Open j4-m opened 1 year ago

j4-m commented 1 year ago

How about adding some VS Code workspace settings? I've got quite a nice set up that I'm using on other projects which makes setting up sniffing/beautifying/formatting in VS Code very straight-forward.

There's gonna be 2 parts to this:

  1. Document the necessary VS Code extensions
  2. Ship a settings.json, the content of which is something like below.

Some of the settings below are for the PHP Sniffer & Beautifier Docker extension. It's pretty neat as it runs PHP_CodeSniffer inside Docker meaning users are not require to have (a particular version of) PHP installed on their machine. The one snag with this is that it requires the container name within the settings, fortunately this is fairly easy to predict with Lando, and could easily be set as part of composer create-project, but obviously mileage may varying using other local dev environments.

{
  "breadcrumbs.enabled": true,
  "css.validate": true,
  "diffEditor.ignoreTrimWhitespace": false,
  "editor.tabSize": 2,
  "editor.autoIndent": "full",
  "editor.insertSpaces": true,
  "editor.formatOnPaste": true,
  "editor.renderWhitespace": "boundary",
  "editor.wordWrapColumn": 80,
  "editor.wordWrap": "off",
  "editor.detectIndentation": true,
  "editor.rulers": [
    80
  ],
  "files.associations": {
    "*.inc": "php",
    "*.module": "php",
    "*.install": "php",
    "*.theme": "php",
    "*.profile": "php",
    "*.tpl.php": "php",
    "*.test": "php",
    "*.php": "php",
    "*.info": "ini"
  },
  "files.trimTrailingWhitespace": true,
  "files.restoreUndoStack": false,
  "files.insertFinalNewline": true,
  "html.format.enable": true,
  "html.format.wrapLineLength": 80,
  "emptyIndent.removeIndent": true,
  "emptyIndent.highlightIndent": false,
  "emptyIndent.highlightColor": "rgba(246,36,89,0.6)",
  "emmet.includeLanguages": {
    "twig": "html"
  },
  "phpsab.docker.standard": "Drupal,DrupalPractice",
  "phpsab.docker.snifferEnable": true,
  "phpsab.docker.fixerEnable": true,
  "phpsab.docker.snifferMode": "onType",
  "phpsab.docker.snifferShowSources": true,
  "phpsab.docker.dockerEnabled": true,
  "phpsab.docker.dockerContainer": "localgov_appserver_1",
  "phpsab.docker.dockerWorkspaceRoot": "/app",
  "[php]": {
    "editor.defaultFormatter": "mtbdata.vscode-phpsab-docker"
  },

}