Inform 7 extension for VS Code

(I decided it’s better to make a separate thread for the Inform 7 VS Code extension, because the extensions for I6 and I7 are are quite different and are released separately. Thread for the Inform 6 extension here.)

I wrote some time ago an Inform 7 extension for VS Code. The features of the initial release are:

  • Highlighting of .ni and .i7x files (story title, headings, comments, text and text substitutions, table names, documentation).
  • Highlighting of Vorple JavaScript commands…
  • Highlighting of Inform 6 inclusions if the Inform 6 extension is installed.
  • Highlighting of Preform files and inclusions.

And now I just released the version 1.1.0 !

The main new feature is the presence of two butons at the top right of the window when an Inform file is open: clicking on them will compile and release the story, respectively. By pressing alt before clicking the release button, it’ll release for testing instead.

A progress bar is shown during compilation, and errors are shown in the Problem panel and in the source.

It will use the compilers in the default location of Inform 7 (on Linux, that’s the location of the command line interface, not the IDE, if that changes something). Il will also respect the project’s settings (story format, making random outcomes predictable…) But you’ll have to edit the settings in the Inform IDE, and restart VS Code when changing them so that the extension reads the new project’s settings.

It hasn’t been tested extensively, and only on Windows. I’d really appreciate if someone tests it on macOS and reports any bugs encountered!

7 Likes

Do you have an update for inform7 v10.1.x?

Not yet, unfortunately. I haven’t really had time. And since I haven’t used Inform 7 for quite a long time, I personally had no need to update the extension.

But knowing other people want an update is motivating! I’ll try to see what I can do next week.

(Of course, if someone wants to do the work, I’m open to merge requests, too. :slightly_smiling_face:)

2 Likes

I’ve just released version 1.3.0 of the Inform 7 extension for VS Code.

It doesn’t add compatibility with Inform 10 yet, however. The only new feature is that you can now fold the headings in Inform 7 source files. Thanks @CrocMiam for implementing that, and again, apologies for taking so long releasing your good work!

The other new thing is that the extension is now available on the Open VSX Registry, so now you can have the extension if you’re using a non-Microsoft-branded version of VS Code such as VSCodium.

If you’re using Inform 10, you can still use the extension for the syntax highlighting, but you won’t be able to compile from within VS Code. That’s my next goal.

6 Likes

I was wondering if there was any chance for you to add an outline provider to the extension? Even just being able to select chapters, parts, etc would be great (as well as “DOCUMENTATION” and examples in extensions). It might be nice to also support selecting rules and definitions, but headings is sufficient in my opinion. One other feature I’d like to request is to reset the indentation level to nothing when pressing enter after a period.

Currently I’m only using this for writing extension code, as a few issues prevent me from using it for the main source. First among those issues are the fact that it doesn’t seem to work with version 10 of Inform (attempting to build uses an older compiler, and attempting to force 10 in the settings fails).

A bigger issue though is that it doesn’t provide all the features of the official IDE, which means I can’t not use the main IDE, and to make matters even worse, the IDE always saves before running even if there were no changes made, which means that anything I do in VSCode is reverted as soon as I press play. (I’m glad I found that out after making only a one-word change.) This is more of a bug in the official IDE though.

Have you tried using your own build script to invoke the compiler?

I have not. I literally tried once, noticed it was the wrong version, tried setting the path to ni in settings to point to the version 10 compiler, found that didn’t work, and gave up at that point. I don’t know anything about how to use the ni program, and it wasn’t really a priority to get it work as I can always just use the official IDE (though its text editor is buggy so it would be nice to be able to not use it).


On another topic, I had a sudden realization that the Index (and the documentation as well) is just a bunch of compiled generated HTML files, so an HTML preview extension should allow me to view it in VSCode. It works really well, but there’s one wrinkle – Inform uses links with a custom inform: protocol to navigate between index pages and reference key icons, as well as a source: protocol to jump to lines in the source code.

Would it be a lot of work to make the VSCode extension understand those protocols?

If that worked, and I can figure out how to playtest the game from VSCode (I think it’s supported? But I don’t know how), the only other missing features from the official IDE would be the skein (which is unfortunate, but I think I can live without it) and the public extension library (which stopped working anyway after I upgraded to Inform 10).

EDIT: Oh right, and the automatic alignment of tables… though that doesn’t work properly anyway.

The outline provider: since the extension already detects the headings for the folding, it should be feasible to also add them to the outline. Not my first priority right now, but I’m keeping that in mind.

Resetting indentation after a period: that’s a good idea I’ve never thought of! Low priority, I guess, but might be really easy to do.

Compilation not working with Inform 10: I know, that’s what I’m working on right now! Hope to make it work soon, but there are quite a lot of thing that change with Inform 10.

Not providing all the features of the official IDE: it’s true that feature parity is not necessarily a goal of the VS Code extension, but I still want to reduce the reliance on it. What are the most important things missing for you? Ah, scratch that, I see you added details in your next post.

Making VS Code understand the custom protocols in the generated HTML: should be feasible, but from what I recall, some things wouldn’t be fun (for me to implement). I think the buttons that paste code in the source simply call randomly generated JavaScript functions (different for each excerpt) and that would be hell to understand in VS Code. (Other minor issue: the HTML won’t follow the VS Code theme.) I’d really like Inform to generate a machine readable documentation/index (say, in JSON) so that I could write my own frontend instead, but well…

Playing the game in VS Code: you need the IF Player extension (also written by me). I have to update it to the latest version of Parchment, but it’s still working in the current state. Admittedly, it’s not that useful as long as you can’t compile your project from VS Code. Also, it’s totally independent right now, so it won’t add the commands to the skein and such. Speaking of which…

The skein: never used that, so it was low priority for me. If really there was some demand, I would think about it, but other things are more important still.

Alignment of tables: As far as I know, elastic tabs are impossible to add to VS Code. :cry: (If they weren’t, someone would have likely written an extension for that already, so I don’t need to do anything about it.)


When I was using Inform (before Inform 10), my workflow was to use the IDE to create projects and extensions and install extensions (that’s done once, so it’s low priority for the VS Code extension), and keep the IDE open with an empty project (to avoid the issue you mentioned) for the documentation. The only issue is when I needed the index. I never used the skein so that one didn’t matter. All the rest was done in VS Code.

Nowadays I don’t use Inform a lot, so I hadn’t had the need to update the extension, but knowing other people are using it motivates me, so don’t hesitate to add your voice to the thread!

I rarely use those buttons, so I could live without them.

The skein is useful, but I’ve seen other tools that serve the same purpose that could probably be used in VSCode, such as this one. So, as mentioned, I could live without it.

Here’s another idea if alignment is impossible – somehow assign a different colour to even and odd table columns. That may make it easier to distinguish the columns even if they’re not aligned. (EDIT: I just realized that this doesn’t work for text columns though… but I don’t have another idea…)

And speaking of tables… did you forget to implement equations into the syntax highlighter? I’ve never actually used them so I wouldn’t call it a priority, but I just checked and they don’t appear to be highlighted at all. They’re not highlighted in the official IDE either, admittedly, but if nothing else I think it would make sense to underline the title like you did with tables.

Also, similar to the highlighting on GitHub, it would be cool if any non-indented, non-heading text in the extension documentation section were highlighted as a comment. That would make example code stand out more.

I found an extension that purports to do it (seemingly via a formatting extension that inserts extra spaces), but I couldn’t get it to work. I also discovered that Inform7 won’t mind if you add spaces before the tab to get it to align. That still breaks down if the table row wraps onto the next line in a non-final column though… but at least it has allowed me to manually align most of the tables I’m using. Thus the only potential improvement would be something that does this automatically.

(EDIT: I’m not sure what I did the first time, but I tried doing the one with two text columns again and managed to align it just fine… but I’m sure issues could still arise in some circumstances when you have multiple text columns.)

Apologies for this bump, but I think keeping the question here might be helpful to someone. When I needed to edit many files in one application, this extension became a lifesaver! I’ve been using it (along with the Inform 6 and Interactive Fiction Player extensions) for about a week, and it’s been a great experience.

I am using 10.1.2

I’ve had to fiddle with settings a bit. I think ni.exe has been replaced by inform7.exe, right? I set that in the path and coding and testing is going fine. I’m having trouble doing releases from within VS Code, though. It’s looking for a path to cblorb.exe.What should I put here (there is no cblorb.exe in my installation)?

I have “inblorb.exe” (just as a guess) in there at the moment, but that errors.

Can anybody help? I can still compile in the IDE, so it isn’t holding me up. Just thought I’d ask if anyone’s working with it in 10.1.2

(thanks for the extension, I don’t think I could have managed this project without it)

2 Likes

I’m using this extension as well, but I only use the extension features for coding and testing. For building the actual release, I use this script (release.cmd) and just run that from the integrated terminal.

cd "C:\Source\External\fiction\Dust\Dust.inform\Build"
"C:\Program Files\Inform\Compilers\inform7" -release -internal "C:\Program Files\Inform\Internal" -external "C:\Users\IkeC\Documents\Inform" -project "C:\Source\External\fiction\Dust\Dust.inform" -format=Inform6/32

"C:\Program Files\Inform\Compilers\inform6" -w~S~DG +include_path=..\Source,.\ auto.inf output.ulx
cd "C:\Source\External\fiction\Dust\Dust.inform"
"C:\Program Files\Inform\Compilers\inblorb" Release.blurb Build\output.gblorb
2 Likes

First, thanks for the kind words!

Regarding your issues, it’s simple: the extension haven’t been updated for Inform 10.

You’re basically right about the executable names, but the issue is that in addition to the names, the arguments you have to give to them are not the same anymore.


I really really have to update the extension, but my life isn’t that stable right now. But thanks for voicing the things you like and the issues! I’ll try to work on it eventually.

2 Likes

No worries, it’s helping me a lot as-is. Thanks again!

1 Like