[Resource] ChoiceScript for Sublime Text

ChoiceScript Syntax Highlighter

:link: [ Github | Package Control ]

:grey_exclamation: Current version: 1.0.0

:warning: Compatible with Sublime 3/4. Not an IDE. Requires a copy of ChoiceScript or CSIDE to playtest your game. View the README for more information.

I decided to start using Sublime to write ChoiceScript. I immediately went to look for a syntax highlighter, and while I found one, it was not what I hoped it would be. So I decided to make my own, and I’m happy enough with the result that I decided to share!

:gem: Features

  • Custom syntax highlighting for the ChoiceScript language.
  • Full support for multireplace and stat charts.
  • Optional custom color scheme for enhanced syntax highlighting.
  • Autocomplete commands to quickly create common lines of code (page breaks, line breaks, choices, if/else statements, stat charts, comments, etc).
  • Auto-indent following appropriate lines of code ( *choice, #options, *if/else, *stat_chart).
  • Spell check for plain text, text for choice options, and text in multireplace.
  • Word wrap automatically enabled, tabs to indent conversion enabled, auto match disabled (to keep from matching quotes).

:bulb: For information on the included autocomplete commands and how to modify the syntax highlighter, its settings, or the color scheme, as well as additional screenshots and tips, view the README on Github.



:hammer_and_wrench: Installation


📦 Package Control (RECOMMENDED)
  1. In Sublime, go to Tools > Install Package Control…
  2. Open the Command Palette by pressing (MAC) CMD + Shift + P OR (PC) CTRL + Shift + P.
  3. Type Package Control: Install Package into the Command Palette.
  4. In the new Package Control window, type ChoiceScript with no spaces.
  5. Select “ChoiceScript” to install the syntax and color scheme.
  6. On a .txt scene file, go to the bottom right of the Sublime window where it says “Plain Text.” Click it and select “ChoiceScript” from the list of syntaxes.
  7. You’re now ready to write ChoiceScript in Sublime!

🛠 Manual Installation
  1. On the ChoiceScript Syntax repository, click “Code” above the files.
  2. Select “Download ZIP” and if prompted, choose where to save the folder.
  3. Extract the contents of the zipped folder.
  4. In Sublime, go to (MAC) Sublime Text > Preferences > Browse Packages… OR (PC) Preferences > Browse Packages… to open your Sublime Packages folder.
  5. Copy and paste the extracted ChoiceScript files directly into the Packages folder.
  6. In Sublime, on a .txt scene file, go to the bottom right of the Sublime window where it says “Plain Text.” Click it and select “ChoiceScript” from the list of syntaxes.
  7. You’re now ready to write ChoiceScript in Sublime!


:art: Color Scheme

Included is an optional color scheme designed for the syntax. Since it was created for this specific syntax definition, it is able to target more specific parts of code to allow for enhanced highlighting.

It recognizes:

  • Variables vs plain text in multireplace.
  • Variables vs operators in *if/*else statements, including and and or.
  • Variables and multireplace vs plain text in choice options.
  • Image file names in *image and *text_image commands.
  • When an *if/else or *selectable_if is immediately followed by an #option without a line break.
  • When a value is set to true vs false in *create, *temp, and *set.
  • When a *page_break is followed by plain text.
  • Commands vs variables vs plain text in *stat_chart.

Some of this does carry over rather well to other color schemes, but the custom color scheme was designed alongside the syntax highlighter to highlight with greater thoroughness and accuracy for ChoiceScript.

🌈 Using the Color Scheme
  1. Go to (MAC) Sublime Text > Preferences > Select Color Scheme OR (PC) Preferences > Select Color Scheme. (On Sublime 3, it’s “Color Scheme…”)
  2. Select the “ChoiceScript” color scheme.
  3. You’re now all set with the ChoiceScript syntax highlighter and custom color scheme!


:camera: Screenshots


Here are screenshots of the syntax highlighter using the optional custom color scheme.



:grey_exclamation: View the README to see screenshots of the highlighter with other color schemes.



As of right now, there are plans to include additional highlighting to support CSLIB code in the next update. If you come across any bugs or issues, please let me know and I’ll try to resolve it as soon as possible.

I hope you guys find this helpful!

:fox_face:

35 Likes

This is a game-changer! I’ve desperately needed a way to highlight and view CS syntax in Sublime, so this is literally a godsend :joy: Thank you so much for developing this and sharing it, it’s working fantastic already!

2 Likes

Thank you!! I had a lot of fun working on it, and I’m very excited to share. I really hope people find it useful. :blush:

2 Likes

This is a life saver! I’ve been using a different syntax ever since I downloaded sublime, and having a CS-compatible syntax completely changes the game :heart_eyes:

A quick question: is the text autocompletion/prediction disabled? I notice the word palette doesn’t come up for me whenever I use this syntax but it works on a different one.

Again, thank you so much for this! :heart:

2 Likes

Ah, I’m so glad you like it!! :blush:

It is, except for the specific autocomplete commands I made! I have all the syntax-specific settings listed on the README here, as well as how to change them.

To re-enable autocomplete, it can be a little convoluted, but the easiest way to do it would be to download the ChoiceScript.sublime-settings on the Github repository, place that in your Sublime Packages folder, which you can get to via (MAC) Sublime Text > Preferences > Browse Packages… OR (PC) Preferences > Browse Packages…

From there, open ChoiceScript.sublime-settings and remove "auto_complete_selector": "keyword.trigger",. Autocomplete will now work on every part of your ChoiceScript files.

I disabled it because of how much plain text ChoiceScript involves. Having an autocomplete come up every time you’re writing can be — for me, anyway — a little annoying, lol.

Hope this helps! :heart:

1 Like

This is life changing! I use Sublime Text for my work and it will be amazing to be able to use it for my hobby :grinning_face_with_smiling_eyes: Thanks so much for doing this!

1 Like