Note:

This site is no longer used and is in read-only mode. Instead please go to our new Moodle Developer Resource site.

Setting up VSCode: Difference between revisions

From MoodleDocs
No edit summary
Line 1: Line 1:
VSCode stub
VSCode stub
https://en.wikipedia.org/wiki/Visual_Studio_Code
https://en.wikipedia.org/wiki/Visual_Studio_Code
 
This plugin
=== Location of function/class braces ===
https://marketplace.visualstudio.com/items?itemName=MateuszLesiak.vscode-moodle-snippets
 
Offers some useful Moodle specific code completion popups.
According to the Moodle coding guidelines
 
https://docs.moodle.org/dev/Coding_style#Functions_and_methods_2
 
"the brace should always be written on same line as the function name."
 
By default VSCode uses the PSR coding convention
https://www.php-fig.org/psr/psr-2/#1-overview
that braces appear on the next line when the internal formatter is used.
(Cmd -K-F on OSX).
 
This can be changed via a file called
 
omnisharp.json
 
Which can be placed either in the root of the project or as a configuration in the users home dir, e.g.
~/.omnisharp/omnisharp.json
 
The following example will put braces on the same line as the function/class declaration
 
<code php>
{
    "FormattingOptions": {
        "NewLinesForBracesInLambdaExpressionBody": false,
        "NewLinesForBracesInAnonymousMethods": false,
        "NewLinesForBracesInAnonymousTypes": false,
        "NewLinesForBracesInControlBlocks": false,
        "NewLinesForBracesInTypes": false,
        "NewLinesForBracesInMethods": false,
        "NewLinesForBracesInProperties": false,
        "NewLinesForBracesInObjectCollectionArrayInitializers": false,
        "NewLinesForBracesInAccessors": false,
        "NewLineForElse": false,
        "NewLineForCatch": false,
        "NewLineForFinally": false
    }
}
</code>
See
https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options

Revision as of 13:41, 10 January 2020