Inform 6 extension for VS Code

So I just finished writing VS Code extensions for Inform 6 and 7. They only add syntax highlighting for the moment. Here are some features.

Inform 6

https://marketplace.visualstudio.com/items?itemName=natrium729.inform-6

  • Highlights .inf and .h files (comments, numbers, routines, keywords and directives, object declarations, strings).
  • Highlight characters, dictionary words and strings in different colours to help the author not mixing them up. Special characters in strings (^, ~, @:e and so on) are highlighted, too.
  • Highlights Inform 6 template files (.i6t, used by I7) correctly, with the paragraph headings and all.
  • Highlights Javascript in strings used as arguments in Vorple’s VorpleExecuteJavaScriptCommand and BuildCommand.

There are no snippets yet, but I plan to add them eventually. A language server for linting, auto-completion and so on would be very cool (I’m quite interested to tackle the challenge), but it won’t be anytime soon.

Inform 7

(I’ve made a specific topic for the extension. Updates for the I7 extension will be announced there!)

https://marketplace.visualstudio.com/items?itemName=natrium729.inform-7

I’m aware another extension already exists, but it made choices I didn’t like (for example, highlighting words such as “is” in sentences), and mine has more features. (And it seems the repo of the other extension isn’t public?)

  • Highlights .ni and .i7x files (story title, headings, comments, text and text substitutions, table names, documentation).
  • Highlight Vorple JavaScript commands, similarly to the I6 extension.
  • Highlights Inform 6 inclusions if the above extension is installed.
  • Highlights Preform files and inclusions.

A language server seems difficult to write because of the natural language. I may add snippets for the Standard Rules phrases.


I hope they will help people other than myself! And of course, comments, bug reports and other contributions are welcome!

10 Likes

Inform 6:
The “Dictionary” directive is no longer deprecated and is very useful.
It also lacks the property “before_implicit”.
Read David Kinder’s “ReleaseNotes.html” and David Griffith’s “ChangeLog” to get the latest modifications and additions to the Inform 6 language:
https://github.com/DavidKinder/Inform6
https://gitlab.com/DavidGriffith/inform6lib

I found this too:
lm_o
lm_s
lm_p (?)
#Ifnot
AskTo
additive (for the grammar of verbs)
compass_look
buffer (Array)
table (Array)
reverse (for grammar verbs)
JumpIn
JumpOn

Do you still think that version 6.12 of the Inform 6 library does not exist (especially the adaptation I made in French) or do you want to integrate these latest new features?

Just pushed a small update to the Inform 6 extension to take account of the features of newer I6 compiler and library.

It includes directives and functions that I forgot to add, and Glulx floating-point numbers. There are still a few minor things that are missing, but they’ll wait for the moment (except if it’s really important).

If you’re interested in adding a debug engine, the one in zilf.zil-language should be fairly easy to adapt, although it only supports Z-machine games (using ZLR as the interpreter).

1 Like

Version 0.2.0 of Inform 6 for VS Code has been released!

It includes some improvements in the syntax highlighting, but the main new feature is the ability to compile a story file from within VS Code by using the “Compile with Inform 6” in the command in the palette (ctr/cmd + shift + P), by clicking on the play button at the top right or by right-clicking on an Inform 6 file in the explorer.

Compiler errors and warnings will then be displayed in the Problems panel and in the source.

vscode-inform6-error

By default, the extension assumes the compiler is in your PATH, but you can specify a custom path to the compiler in the settings.

The settings also allow to add additional arguments when compiling (by default the command compiles with no args), but it is better to add ICL commands in your Inform file, with !% comments.

Compiling from VS Code is mainly for testing the story. When releasing it, it’s better to use Inform directly from the command line, and using the right arguments (e.g. -~D).

(I’ve only tested on Windows, so let me know if you have any problem.)

The full changelog is available in the repo.

As usual, any comment and bug reports are welcome!

1 Like

This is great. I have been using it with my current WIP over the last week.
I was using using JIF & WIDE and IMAGINATE before those, but other than not being able to run the interpreter directly, I have found no problems.

Suggestions for future (depending on degree of difficulty to implement)

  • Setting a path to the interpreter (eg. winfrotz or gargoyle) to allow testing of the Z5 file.
  • A way to allow the user to change the colours of the different highlights.

A very pleasing and usable extension to VS Code. Much appreciated.

Thanks! :blush:

About your suggestions:

I have the plan to write an extension that will make it possible to open a Z-machine or Glulx file directly in VS Code next to your source. (A bit like when you preview a Markdown file in VS Code). I have other things to do right now though, so it’ll have to wait.

If you really think it’s necessary, it should be quite easy for me to make the extension open the file automatically at the end of the compilation.

In the meantime, if you have a command line interpreter (i.e. dumbfrotz), you can play your story in VS Code’s integrated terminal.

The colours are normally handled by your current theme. The main thing I can do is i.e. make a word be coloured as a keyword instead of a class. But ultimately it’s the active theme that chooses how a keyword or a class should be coloured.

If you have some specific things that trouble you in the colours, please tell me and I’ll see what I can do!

Thanks for the response. They were only suggestions - no urgent need for any of them. I open File Explorer and double click the .Z5 file and test what I need. It doesn’t take much longer.
I didn’t realize the colours were tied to the themes. I’ll have a play around to see if there is any other arrangement I might prefer. However, I can live with the way it is as it gives me all I need for now.

Thanks again for your work on this. I’ll watch for further updates if and when they occur.

Version 0.3.0 of Inform 6 for VS Code has been released!

The main new feature is that we can now automatically open story files just after compilation. When the new openStoryAfterCompilation setting is set to external, VS Code will attempt to open newly created story files with the default application associated with its extension (e.g. winfrotz for .z5, or Lectrote for .ulx).

(This is for you, @R2T1!)

Apart of that, there were quite a lot of internal changes (see the changelog), so if you encounter a bug, please report. :slight_smile:

1 Like

WOW. I wasn’t expecting this so soon. Many thanks for this. Being able to see/test my code as I write is great.
Excellent job.

1 Like

Version 0.4.0 of Inform 6 for VS Code has been released!

The main change is that the button at the top right now compiles the story in debug mode (with -SD) by default. To release a story, you can press alt before clicking: it will be compiled with -~S~D.

(Both commands are still available in the palette and by right-clicking a file, of course.)

Also, stories in formats other than Z5 are now properly opened after compilation. (Previously, only Z5 files would be opened.) Thanks @JasonLautzenheiser for spotting this bug!

2 Likes

I decided to make a new topic for the Inform 7 extension, since it’s quite different from the Inform 6 one, and they are releases independently.

The new topic is here, with a new release of the Inform 7 extension!

Thanks so much for this! I’ve been debating whether to use ZIL or I6 for my next project and am leaning toward I6 primarily because of the C-like syntax. I’ve never touched lisp so it’s a bit more intimidating.

3 Likes