This plugin enables syntax highlighting for kOS scripts .ks in Visual Studio Code.
It leverages whatever VS Code theme you have enabled, so it should work with any theme you choose.
For a version of Visual Studio Code without Microsoft's telemetry, you can check out VSCodium.
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X(orCmd + Shift + Xon macOS). - Search for
kOS Syntax Highlighting | Kerbal Space Program. - Click Install.
You can also find the extension on the Visual Studio Marketplace
- Download the latest release from the releases page
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X(orCmd + Shift + Xon macOS). - Click on the
...menu in the top right corner of the Extensions view and select Install from VSIX.... - Select the
.vsixfile you downloaded. - Click Install.
Will be added soon.
If you want to customise the colours for a specific kOS syntax scope, here's how you can do it:
-
Open VS Code.
-
Find the Scope Name:
- Open the
kos.tmLanguage.jsonfile. - Press
Ctrl + Fand search for the keyword you want to colour. - Copy the scope name (e.g.,
support.function.kos) directly above the keyword.
- Open the
-
Open the VS Code Settings JSON file:
- In VS Code, Press
Ctrl + Shift + P(orCmd + Shift + Pon macOS) and typePreferences: Open Settings (JSON).
- In VS Code, Press
-
Add the following configuration to your
settings.jsonfile:{ "editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "support.function.kos", // Replace with the scope you want to customise "settings": { "foreground": "#FF0000" // Replace with your desired colour } }, //<-- Remove this comma if it's the last item in the list ] } }-
4.1 Add More Than One
-
You can add multiple customisations by adding more objects to the
textMateRulesarray:{ "scope": "variable.parameter.kos", // Replace with the scope you want to customise "settings": { "foreground": "#FF0000" // Replace with your desired colour } }, //<-- Remove this comma if it's the last item in the list
-
-
-
Replace the
scopeandforegroundvalues:- Use the scope name you copied from the
kos.tmLanguage.jsonfile. - Replace the
foregroundvalue with your desired colour.- Note: W3Schools has a Colour Picker you can use.
- Use the scope name you copied from the
-
Save the
settings.jsonfile.
You will need to have Node.js installed to build this extension.
-
Install Node.js:
If you have to install Node.js, you can download it from the official website.
- NB: After installation, If you can't see the
nodeandnpmcommands in your terminal, try restarting your computer to ensure they've been added to your PATH.
- NB: After installation, If you can't see the
You can build the VSIX file for this extension using the vsce package. Here's how to do it:
-
Install
vscePackage:npm install -g vsce
-
Navigate to the VS Code Folder: It should be the folder that contains the
Package.jsonfolder.-
Windows:
cd path\to\VSCode
-
macOS/Linux:
cd path/to/VSCode
-
-
Build the VSIX File:
vsce package
This should output a VSIX file in the root of the project folder, from which you can install the extension manually.