3 stable releases

Uses old Rust 2015

1.1.0 Jul 18, 2017
1.0.5 Jun 1, 2017
1.0.4 Apr 25, 2017

#2 in #kailua


Used in 3 crates

MIT/Apache

450KB
7.5K SLoC

Rust 5K SLoC // 0.1% comments Lua 2.5K SLoC // 0.6% comments

🌴 Kailua (crates.io)

한국어

Kailua is an experimental type checker and integrated development environment (IDE) for the Lua programming language (currently only Lua 5.1 is supported).

The detailed documentation is available here.

Installation and Usage

Kailua can be used as a standalone checker or an IDE plugin.

Standalone Checker

To install a standalone checker, install Rust first (1.15 or later required), then type the following:

cargo install -f kailua

(-f will cause the existing installation to be upgraded.)

You can run kailua check <path to the entry point> now.

You can also run kailua check <path to the directory>, if you have kailua.json or .vscode/kailua.json in that directory. The configuration format is described in the later section.

Visual Studio Code

Kailua can be used as an IDE support for Visual Studio Code. Install Kailua by typing ext install kailua from the Quick Launch (Ctrl-P). If you are not on Windows, you should also install the standalone checker as above.

You will see a warning that the configuration file is missing when you open a folder containing Lua codes. You need it for real-time checking.

You can either create .vscode/kailua.json by hand, or search "Kailua" from the Command Palette (Ctrl-Shift-P) to edit one.

The following content is required for .vscode/kailua.json, in case you are editing it by hand:

{
    "start_path": "<path to the entry point>",

    "preload": {
        // This indicates that we are using Lua 5.1 and all built-in libraries of it.
        "open": ["lua51"],
    },
}

You need to reload the current window (Ctrl-R or Cmd-R) to apply the configuration.

Your First Kailua Code

Once you've set the entry point, you can write your first Kailua code:

--# open lua51
print('Hello, world!')

If you are using the configuration file, the first code can be made much simpler:

print('Hello, world!')

Play a bit with this code to see which errors Kailua can detect.

License

Kailua is dual-licensed under the MIT license and Apache license 2.0 at your option. By contributing to Kailua you agree that your contributions will be licensed under these two licenses.


lib.rs:

Type checker for Kailua.

Type checking involves four types:

  • kailua_check::env::Context is a global context for all checked files. It also exposes an interface to the type environment, kailua_types::env::Types.

  • kaliua_check::env::Env is a per-file context. The checker will also build its own Env for newly loaded files, but the first Env should be given explicitly.

  • kailua_check::options::Options is a configurable portion of the type checker. Currently it allows you to configure the require path and the actual loading process.

  • kailua_check::Checker is the actual checker. Due to the internal architecture, it also holds some side information depending on the input chunk (and cannot be put to Env due to the lifetime mismatch).

After the type checking, Context can be extracted into the Output for later analysis.

Dependencies

~5MB
~95K SLoC