Difference between revisions of "Visual Studio Code"

4,577 bytes added ,  05:33, 3 December 2018
Added categories
imported>Qazaaq
(added link to other editors)
imported>Qazaaq
(Added categories)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Text Editors]]
[[Category:Scripting]]
'''Visual Studio Code''' is a source code editor developed by Microsoft. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is also customizable, so users can change the editor's theme, keyboard shortcuts, and preferences. It is free and open-source, although the official download is under a proprietary license.
'''Visual Studio Code''' is a source code editor developed by Microsoft. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is also customizable, so users can change the editor's theme, keyboard shortcuts, and preferences. It is free and open-source, although the official download is under a proprietary license.


Line 12: Line 10:


===Install packages===
===Install packages===
* Papyrus [https://marketplace.visualstudio.com/items?itemName=plankton020.papyrus]
* Papyrus [https://marketplace.visualstudio.com/items?itemName=plankton020.papyrus] (syntax highlighting)
* Papyrus Compiler [https://marketplace.visualstudio.com/items?itemName=mr-andersen.vs-papyrus-compiler] (run the Papyrus compiler from the command menu)


==Usage==
==Usage==


TBD
After installing VS Code, install the Papyrus packages by browsing to the package's extension page and click install or the VS Code's extension installer (CTRL+SHIFT+X)
 
If your project is using project files (.ppj) you may want to associate .ppj files as XML
Go to File > Settings and add the following to *user settings*:
 
<source lang="javascript">
"files.associations": {
    "*.ppj": "xml"
}
</source>
 
User settings should look something like this:
 
<source lang="javascript">
{
    ...
    "editor.fontSize": 13,
   
    "files.associations": {
        "*.ppj": "xml"
    }
 
    ...
}
</source>


===Compilation===
===Compilation===


TBD
If you want to compile your Papyrus scripts from within Visual Studio Code you can use the Papyrus Compiler package (see packages section). The package contributes commands to VSC for running the Papyrus compiler. See the package homepage for setup.
 
Alternatively you can utilize VS Code's build and tasks system.
 
====Using the build and tasks system====
 
Note: Replace occurences of '''<GAME-DIRECTORY>''' with the path to the directory where your game is installed (Eg.: '''C:\Program Files (x86)\Steam\steamapps\common\Fallout 4''')
 
=====Compile single file using default build task=====
 
# First add the [[#Files|ScriptCompileDevVS.bat]] to your '''<GAME-DIRECTORY>\Data\Scripts\Source\User''' directory. The bat file contains basic compiler configuration for development.
# If not exists create a directory named '.vscode' (without quotes) in your '''<GAME-DIRECTORY>\Data\Scripts\Source\User''' directory.
# Add the file [[#Files|tasks.json]] in the new .vscode directory.
# In tasks.json make sure the directory paths in the windows.command property are correct.
# Save tasks.json
 
Now, you may test to see if everything is working as expected by opening one of your .tsc files. Press CTRL+SHIFT+B (Run Build Task) to compile.
The built-in terminal should automatically open and output the results.
If everything has been configured correctly you should see the compilation success message.
 
Tasks can be tweaked to better suit your particular needs. Please consult the documentation for more information: https://code.visualstudio.com/docs/editor/tasks
 
For example you may create a task that runs the compiler based on a [[Papyrus project file (.ppj)|projects]]
You may also create a task for each step in the workflow (development, release, final etc.)
 
=====Compile file on CTRL+S=====
 
If you want to compile the edited file every time you save the file (CTRL+S) you can add a hook in keybindings.json
 
# Choose File > Preferences > Keyboard Shortcuts
# Click the keybindings.json link at the top of the screen (below the search input)
# In your keybindings.json add the following JSON object to the JSON array (between the brackets)
 
<source lang="javascript">
    {
        "key": "ctrl+s",         
        "command": "workbench.action.tasks.build",
        "when": "editorLangId == papyrus"
    }
</source>
 
This will run the build task for the currently edited Papyrus file each time you save the file using the CTRL+S shortcut.
Please note that the task will not run if save is triggered from elsewhere in VS Code (eg. Menu - File > Save)
 
Read more about keybindings here: https://code.visualstudio.com/docs/getstarted/keybindings
 
===Files===
 
'''ScriptCompileDevVS.bat'''
 
<source lang="text">
set compilerPath=%2
set gameDirectory=%~3
 
%compilerPath% %1 -f="%gameDirectory%\Data\Scripts\Source\Base\Institute_Papyrus_Flags.flg" -i="%gameDirectory%\Data\Scripts\Source\User;%gameDirectory%\Data\Scripts\Source\Base" -o="%gameDirectory%\Data\Scripts"
</source>
 
'''.vscode/tasks.json'''
 
<source lang="javascript">
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile Papyrus Script (development)",
            "type": "shell",
            "windows": {
                "command": ".\\ScriptCompileDevVS.bat '${file}' 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Fallout 4\\Papyrus Compiler\\PapyrusCompiler.exe' 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Fallout 4'",
            },
            "presentation": {
                "reveal": "always"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
</source>


==See Also==
==See Also==
*[[:Category:Text Editors|Other Text Editors]]
*[[:Category:Text Editors|Other Text Editors]]
[[Category:Text Editors]]
[[Category:Scripting]]
[[Category:Tooling]]
Anonymous user