2 stable releases

Uses old Rust 2015

1.0.5 Jun 1, 2017
1.0.4 Apr 25, 2017

#1 in #kailua


Used in 2 crates (via kailua_langsvr)

MIT/Apache

41KB
1K SLoC

🌴 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:

Language server protocol types for Kailua.

This crate closely mirrors the version 3.0 of the Language Server Protocol, and provides both serde::Serialize and serde::Deserialize implementations for most types, with the following deviations:

  • Enums are mapped to Rust modules.

  • Anonymous nested interfaces are given unique names from its field name. Since this results in many ambiguous types for client capabilities, client capabilities are put to a separate module client_caps.

  • Some types like number | string are not yet properly implemented and fixed to a most probable type.

  • ServerCapabilities.textDocumentSync should be a TextDocumentSyncOptions in 3.0, but this causes a bug in vscode-languageclient<=3.2.0, so it is reverted to a backward-compatible TextDocumentSyncKind.

Dependencies

~0.7–1.6MB
~34K SLoC