Visual Studio Code

From mediawiki.org
Jump to navigation Jump to search

Visual Studio Code is a free cross-platform IDE built on open source with a diverse plugin ecosystem that can be used for MediaWiki Development.

The Wikibase team at Wikimedia Deutschland is currently trialling its use as an IDE and this page serves as the documentation of that effort (hoping it will be useful or others).

Notable features[edit]

This one might annoy you https://code.visualstudio.com/docs/getstarted/userinterface#_preview-mode

Recommended Plugins[edit]

PHP Tools for VS Code[edit]

Licence required (after 1 month trial). Contact Addshore.

Notes

  • Simple refactorings are done through the "rename symbol" option not "refactor"
  • Very receptive to issues being filed, and fixes often in 1 day. (issue tracker)

IntelliJ IDEA Keybindings[edit]

Highly recommended if you are coming from PhpStorm or IntelijJ.

Php Debug[edit]

Debug support for PHP with XDebug.

If you're using Windows, WSL2, or docker containers you might find this blog post useful.

The plugin comes with default configuration that will work in many cases.

Issues with path mappins[edit]

If you have problems with VSCode detecting the mappings between your files and the debug sessions you may need to set some path Mappings.

			"pathMappings": {
				<remote-mediawiki-path>: "${workspaceRoot}"
			}

Avoid breaking on uncaught exceptions, warnings etc.[edit]

By default the plugin will break on "uncaught exceptions and errors / warnings / notices".

This may not be desirable and can be turned off.

  1. Using the sidebar, select the "Run" panel.
  2. At the bottom of the panel expand the "Breakpoints" section (collapsed by default).
  3. Untick the "Everything" option.

Phabricator links[edit]

Provides links to Phabricator objects.

"phabricator-links.url": "https://phabricator.wikimedia.org"

Settings[edit]

search.useIgnoreFiles[edit]

MediaWiki includes a .gitignore file that the IDE will use to ignore files and directories during search. In MediaWiki this includes the skins and extensions directories. In order to search files in these directories you will need to set the search.useIgnoreFiles to false in your project specific configuration or higher. A default of true may be useful in order projects, so the recommended location is in project configuration.

    "search.useIgnoreFiles": false

editor.wordSeparators[edit]

In order to allow selection of PHP variables (including the $) by double clicking on them you need to alter your editor.wordSeparators [1]

You can do this for individual languages in your settings.json file [2]

    "[php]": {
        "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?"
    }

explorer.autoReveal[edit]

By default opening a new file will jump to that location in the sidebar. This can be annoying in large projects, the bellow will stop that jumping around!

    "explorer.autoReveal": "focusNoScroll"

Plugins to avoid[edit]

  • Render line endings: Has performance problems
  • Render whitespace at end of lines: Has performance problems

References[edit]