Language Server for Inform 6 (+clients for eclipse and vscode)

Dear IF community! I’ve decided to go open source with my homegrown project that’s been occupying me for some months now. It is a Language Server implementation for Inform 6. It is right now in a really early alpha stage but I’ve come to the conclusion that it might already be useful in its current state for anyone working with Inform 6.

The project is written in the XText framework and is mainly served for eclipse. https://github.com/toerob/ls4inform6/. But I’ve also written a bare basic client implementation for visual studio code, found at:
https://github.com/toerob/inf6langtools

Installation instructions for both are found in the readme file.

The really nice thing with a Language Server is that it will only require a thin client (or sometimes none at all) to be fully working in any Editor supporting the Language Server Protocol. (The ones providing this can be found here: https://microsoft.github.io/language-server-protocol/implementors/tools/)

I’m interested in hearing what features you might suggest and if there are any collaborators wanting to join in. Writing grammar is very time consuming and at the present stage the plugin is more of an outliner with some pretty nice bonus effects, such as “go to references” on direction properties and class names. (In eclipse it is also possible to navigate via include statements to other files). Plus that it checks the overall syntax of your written code.

Bear in mind though that the parser is a of a “fuzzy” kind, that means it in this case that it won’t parse (to any great extend at least) expressions written inside global or local routines. And therefore only performs analysis on broader code structure. A full parser is something I wish to incorporate further ahead. It won’t happen anytime soon though. Also bear in mind that there are some trickiness involving preprocessed directives. It will have a problem parsing conditional properties inside objects as it will for now simply ignore such rows completely. Those are mostly found in the library files and usually not the game file itself.

Please let me know what you think!

Tomas

4 Likes

That’s great! (Guess I won’t have to write a language server myself, after all!)

I don’t have time to look at your work right now, but I’ll do as soon as possible. I suppose you don’t mind if I include it in my Inform 6 VS Code extension? (If it’s production-ready, of course.)

(I would have prefered a language server written in JavaScript/TypeScript, so that users do not need to have Java installed, but well. I see that xText is based on ANTLR, and that ANTLR can output JavaScript. Do you know if there is a way to have your work output JS? That would be great.)

That’s fine as long as you mention it (at least by including the MIT License file) There’s already a vscode extension (inf6langtools) out there that co-exists with your extension so if you decide to incorporate the LS I think it’s worth mentioning somewhere that if the users have installed both of the extensions it will also analyze the code twice. (And have an additional outliner.) My main objective now will actually be to create thin clients for the most popular editors before improving the server so it is available everywhere.

Regarding “production ready”… It’s more of a pre-alpha and I hope to emphasize that with the 0.5.0 version, but I do believe it is stable (although pretty rudimentary) for what most game writers do with it but there will of course be edge cases where it can’t parse and report an error where the compiler will happily compile. I made it available first and foremost so it can incrementally become more capable and to speed up the bug discovery but also to keep me motivated.

About the JavaScript question, I do believe that is fully possible since xtext supports crafting web editors that run on javascript but I don’t have any further insight in this right now.