Presenting Haxe-neovim a new toolchain to build NeoVim plugins

Hello, fellow NeoVim enthusiasts! Today, I’m excited to introduce a new toolchain for building neovim plugins using Haxe. Haxe is a statically typed language that is known for its safety and efficiency, making it a great choice for building complex applications.

While Lua is a popular language for building neovim plugins, it can be prone to errors that are only caught at runtime. This can be frustrating and time-consuming, especially when trying to debug larger projects. Haxe, on the other hand, is designed to catch these kinds of errors at compile-time, reducing the likelihood of bugs and making the development process more efficient. This is the reason why I started this project. I want to make clear that, the output of this toolchain will be Lua code that then is run like any other normal NeoVim plugin written in Lua.

But what exactly is Haxe? At its core, Haxe is a multi-platform programming language that compiles to a variety of targets, including JavaScript, C++, Python and of course Lua. It was originally created as an alternative to ActionScript but it is now used in a variety of industries, including game development, web development, and even server-side applications.

Haxe also has a powerful type inference system, which can often guess the correct data type without the need for explicit annotations. On top of that, the type system is very powerful and flexible, forget what do you know about classic static typed languages like Java or C++, Haxe type system is very expressive. Exausthive pattern matching, algebraic data types (ADT), and Generics are only some of its capabilities.

In addition to its safety features, Haxe also has a lot of QOL features that make programming more pleasant while keeping it performant. Static extensions (similar to rust traits) that allows to extend any type with functions that looks like methods, automatic type conversions that make the proper calculations, inline functions that allow to write abstractions with zero runtime cost, and some more.

If you’re interested in trying this out, I’ve created an example/template repository containing all you need to create a NeoVim plugin using Haxe here. It includes CI/CD to build and test your plugin, automatically generate docs and even publish releases.

I use this toolchain in my personal NeoVim configuration which I use at work daily, so it is not just a proof of concept, but something that I really use and that arised from a need. As I mentioned earlier, I was frustrated by the high number of stupid mistakes I was making in Lua because the lack of type checking, even with the great Folke’s neo-dev plugin, and sumneko-lua lsp+annotations the type checking is too weak for my taste.

Please let me know what do you think!

2 Likes

While Lua is a popular language for building neovim plugins, it can be prone to errors that are only caught at runtime. This can be frustrating and time-consuming, especially when trying to debug larger projects.

I am totally with you on this. I read haxe was used for dead-cells so that’s definitely a plus :slight_smile:

haxe seems to have definitely neat features (looking at you type inference). I wanted to try teal but the (very) little moment I tried, it seemed like a lot of overhead for not much type-safety. I dont think fennel bring much too in that regard ? I wanted to try typescript2lua but I read it had limitations.
Do you have any experience with those alternatives or you tried haxe first ?
Is there a haxe lsp ?
Feel free to add and structure this page Configuration · neovim/neovim Wiki · GitHub .