Editors
Editors can show Luma’s errors while you type: a red line under the mistake, with the compiler’s message, before you run anything. The luma command has the language server for this built in, luma lsp. The editor starts it and talks to it; you don’t run it yourself.
What it does now:
Errors as you type. It checks each open file with the compiler itself, so it finds exactly what
luma runandluma buildwould. It shows each statement’s error, not only the first (up to 50 in a file); a variable whose declaration has an error still counts as declared, so its uses don’t all show errors too. A mistake in the syntax, such as a missing}, is shown alone: the rest of the file can’t be read until it is fixed.Errors in imported files. An error in a file you import is shown in that file, and at the
importline too. Files open in the editor count with their unsaved changes.Hover. Holding the mouse over a name shows what it is: a variable’s type (
nums: [int]), a function’s or method’s header (fn twice(n: int): int), an obj’s fields, a trait’s methods. Over a built-in name or keyword, such asprint,walkorlock, it shows the start of its page in this manual.Go to definition. It jumps to where a variable, function, method, field, obj type or trait is declared, also in imported files; on an imported file’s name, to that file.
Completion. After a dot it offers what the value has: a str’s methods, a list’s, an obj’s fields and methods, an imported file’s
pubnames, or whatcrypto.,date.,http.and the other built-in modules have. Elsewhere it offers the variables you can use there, the functions, types and imported files, the built-in functions and the keywords; after a:, the types.Signature help. While you type a call’s arguments, it shows the function’s header with the argument you are at marked:
fn add(a: int, b: int): int. It works for functions, methods, built-in functions and modules (crypto.sha256(data[, key]), the part in brackets optional), function values, andService(...)for an obj withinit.Find all references. It lists every place a variable, function, method, field, obj type or trait is used: in every
.lumafile of the folder you opened, also files that aren’t open, also inside"${...}".Rename. It renames a name everywhere it means the same thing: in all those files, and only there (another function’s
nstaysn). First it compiles the files with the new name: if one that compiled would break, because the name is taken there or a trait needs the old one, it renames nothing and says why. Built-in names,selfand imported files can’t be renamed; to rename a file, rename it and then its imports.Renaming an obj’s field also changes its name in JSON:
convertreads and writes fields by their names. If a field’s name is part of a JSON format others use, keep it.
Hover, go to definition, completion and find all references work while a file has an error too: for the code the compiler could understand.
VS Code
The extension is in editors/vscode in Luma’s source. It adds highlighting for .luma files and starts luma lsp.
Make the extension once (this needs Node.js):
cd editors/vscode
npm install
npx @vscode/vsce package --allow-missing-repository --skip-license
code --install-extension luma-0.1.0.vsixThe extension runs the luma command it finds on the PATH. If it isn’t there, give the full path in VS Code’s settings:
{
"luma.path": "/home/ann/luma/luma"
}Neovim
Neovim 0.11 and newer starts language servers on its own. In init.lua:
vim.filetype.add({ extension = { luma = "luma" } })
vim.lsp.config("luma", { cmd = { "luma", "lsp" }, filetypes = { "luma" }, root_markers = { ".git" } })
vim.lsp.enable("luma")Helix
In languages.toml:
[language-server.luma]
command = "luma"
args = ["lsp"]
[[language]]
name = "luma"
scope = "source.luma"
file-types = ["luma"]
comment-token = "//"
indent = { tab-width = 4, unit = " " }
language-servers = ["luma"]Other editors
Any editor that speaks the Language Server Protocol can use it: start the command luma lsp for .luma files. It reads and writes the protocol on standard input and output, and wants the whole text of a file with each change.