No VSCode formatter for Tweego (.tw) files

Hello! I’ve been using VSCode and Tweego to make a game with Snowman. VSCode normally includes a way to format a file automatically, but when I try this (ctrl + shift + P → type ‘format document’), I get the message that no formatter is installed. Of course, this is because no formatter for .tw files has been created, but it still bugs me.

Straight-up creating a Tweego formatter would be a solution to this, but I don’t have the time right now. I feel there should be another way that involves using a formatter for a different, but similar file type (maybe .ejs?) on .tw files, but don’t know if it would work. Does anyone else have ideas/has anyone else run into this problem and found a way to some kind of solution?

I’m not tagging this with ‘Snowman’ specifically because I think it applies to all .tw files, no matter the Twine format.

Edit: One thing I’ve found that is minorly helpful is temporarily changing the language association for .tw files (from this Stackoverflow thread How to associate a file extension with a certain language in VS Code - Stack Overflow) from Tweego to something else, which allows you to apply to formatter associated with the new language before you change it back. The HTML formatters are kind of useful, and I also downloaded an .ejs formatter so I can change the file language to ejs (which ruins the syntax highlighting, but whatever), format it with the ejs formatter, and then change it back to Twee. It doesn’t work great, but it’s something.

The issue is that a Twee Notation (tw or twee) file can contain a number of different language syntaxes / content types.

For example, there is the Twee Notation syntax itself, which is used to indicate the Name, Tags, Meta-data, and Content Area of each Passage contained in the file.

Then there are the Macro languages of each of the different Story Formats.

And finally there are the HTML, CSS, and JavaScript related code that can also appear in the content of a Passage.

There is also the matter that. unlike many programming languages, line-breaks placed within the contents of a Passage may be automatically converted in HTML <br> elements unless some means is used to suppress that behaviour.

2 Likes