Set up your editor
Get completion, type checks and formatting for your package in any editor that runs the Lua language server. Editor support comes from LuaLS and StyLua, set up by files DatumHue writes into your package.
The files in your package
datumhue pkg new writes these files into a new package, and
datumhue pkg refresh writes them again into an existing one:
| File | What it does |
|---|---|
datumhue.d.lua | describes the whole datumhue.* API, exactly as your DatumHue has it, for completion and type checks |
.luarc.json | tells LuaLS to read datumhue.d.lua, lib/ and deps/, and that datumhue is a global |
.stylua.toml | sets StyLua to the style the new package uses |
tests/test.d.lua | describes the globals of test files, in a package with a tests/ folder (Package testing) |
None of them is part of the package itself: running it and packing it leave them out. Refresh them after you update DatumHue, so completion offers the new API:
$ datumhue pkg refresh ballpit
Install the tools
Install LuaLS, version 3.18.1 or later, which
reads Lua 5.5, and StyLua once.
Open your package's folder in an editor that runs LuaLS, and it reads
.luarc.json from there. Run stylua init.lua lib tests in the package's
folder to format its Lua. StyLua reads Lua 5.4: a file that uses what Lua
5.5 adds, such as a global declaration, local <const> a, b or
...args, is one it reports an error in and leaves unformatted.
Book pages in Helix
A book page (.dhml) is Markdown with KDL blocks in it, so an editor's
Markdown mode highlights it. In Helix, add the extension to the Markdown
language in languages.toml:
[[language]]
name = "markdown"
file-types = [{ glob = "*.dhml" }, "md", "markdown"]