This extension for Visual Studio Code adds snippets for various languages in use by Wikimedia at its sites running MediaWiki software. Among those languages are Lua, which is used as a templating language by the Scribunto extension.
The extension is hosted at GitHub and Visual Studio Marketplace.
Type part of a snippet, typically by writing something like mw.ustring.byte
, make sure the highlighted entry is the one you want, press tab
or enter
, and the snippet unfolds. Inside the snippet there are one or more highlighted areas, these can be replaced, and it is then possible to tab to next item that can be replaced. Sometimes the highlighted area cover the comma before the argument, that happen when the following is an optional argument.
The snippets have a prefix that is the method name, and inside Visual Studio Code you might type additionel specifiers. Those are typically the class name or the name of an argument. It is also possible to write the snippets number, even if it is a bit awkward. Instance methods are found the same way as class methods, but the leading part is skipped on the assumption that it shall be appended to a variable of some sort.
As this is snippets, there is no Intellisense available. That is a bit unfortunate, as the user must learn the method names. They do although work as a typing aid, and especially well as an aid to get the arguments right.
The set of snippets are mostly motivated by what I (the author) have found usefull, so please don't expect the list to be complete!
Not included, available through other extensions.
Libraries loaded by Scribunto
- frame — interactions with calls from Mediawiki
Libraries available through the “mw” structure
- mw — basic functions from Scribunto to interface with Mediawiki
- hash — basic hashing
- html — create and manipulate html tags
- language — get, create and manipulate language objects
- message — create and manipulate messages
- site — access site-specific information
- text — additional manipulation of strings
- title — get, create and manipulate title objects
- uri — create and manipulate encoded uri strings
- ustring — manipulate unicode strings
- wikibase — access repo-specific information
Libraries that must be explicitly required
- libraryUtil — manipulate arguments
Libraries that use bootstrapping
- adapt — create and manipulate assertions; “subjects” and “expectations”
- frame — create and manipulate examples; “describe”, “context”, and “it”
- spy — create and manipulate spies; “carp”, “cluck”, “croak”, and “confess”
There a few additional snippets
- class-table — table-based class structures, see Object Orientation Tutorial (“Simple metatable-based class” and “Inheritance”)
- Install Visual Studio Code 0.10.1 or higher
- Launch
code
- From the command palette
Ctrl
-Shift
-P
(Windows, Linux) orCmd
-Shift
-P
(OSX) - Select
Install Extension
- Choose the extension
- Reload Visual Studio Code