Difference between revisions of "Visual Studio Code"
imported>ChikkenChazer (Introduce Text Editors/Visual Studio Code page) |
imported>Qazaaq (Added categories) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
'''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== | ||
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=== | ||
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== | |||
*[[:Category:Text Editors|Other Text Editors]] | |||
[[Category:Text Editors]] | |||
[[Category:Scripting]] | |||
[[Category:Tooling]] |
Latest revision as of 04:33, 3 December 2018
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 based on Electron, a framework which is used to deploy Node.js applications for the desktop running on the Blink layout engine. Although it uses the Electron framework, the software does not use Atom and instead employs the same editor component (codenamed "Monaco") used in Visual Studio Team Services (formerly called Visual Studio Online).
See Wikipedia's page for more information.
Installation[edit | edit source]
Install Visual Studio Code[edit | edit source]
Go to the Visual Studio Code website, download the setup file, and run it.
Install packages[edit | edit source]
- Papyrus [1] (syntax highlighting)
- Papyrus Compiler [2] (run the Papyrus compiler from the command menu)
Usage[edit | edit source]
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*:
"files.associations": {
"*.ppj": "xml"
}
User settings should look something like this:
{
...
"editor.fontSize": 13,
"files.associations": {
"*.ppj": "xml"
}
...
}
Compilation[edit | edit source]
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[edit | edit source]
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[edit | edit source]
- First add the 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 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 projects You may also create a task for each step in the workflow (development, release, final etc.)
Compile file on CTRL+S[edit | edit source]
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)
{
"key": "ctrl+s",
"command": "workbench.action.tasks.build",
"when": "editorLangId == papyrus"
}
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[edit | edit source]
ScriptCompileDevVS.bat
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"
.vscode/tasks.json
{
// 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
}
}
]
}