What ela --lsp gives
In the terminalela --spec what-ela-lsp-gives
An editor starts ela --lsp and talks to it over stdin and stdout in the Language Server
Protocol. Every editor's setup below is the same three things: the command ela --lsp, the
language ela, and the files *.ela and scripts whose first line runs ela
(#!/usr/bin/env ela). The server answers from the ela it runs:
| The editor asks for | The server gives | As |
|---|---|---|
| diagnostics, as you type | each finding of the script, an error or a warning, at the word it stands on | ela --lint |
| hover on a mistake | the message and its entry: the rule, why, wrong and right, the spec topic | ela --explain |
| hover on a keyword | its section of the spec | ela --spec |
| hover on a built-in | its call and what it does | ela --builtins |
| hover on a proc the script declares | its signature, with its results where it declares them: proc split_host(addr: string) -> (host: string, port: number) | procs |
| formatting | the script as --fmt lays it out; nothing while it does not parse, which its diagnostic says | ela --fmt |
| completion | every built-in proc, package proc and shell built-in; str.sp finds str.split | ela --builtins |
| rename | a name the script declares, a variable, a proc, a parameter, a constant, a struct, an enum, a member, a field or an import's name, and every use of it in the open documents: in code, as $name and inside a double-quoted string. A command's words, a package's procs and ela's own names stay; a document that does not parse is left out, and the one renamed in must parse | ela --lint |
| go to definition | on a proc's name, its proc line, in the script or, after an import's name, in the file imported; on an import's line, the file, a lib: one found in the library folders | ela --check |
| semantic tokens | the colours the prompt gives a line: keywords, strings, variables, commands, numbers and comments | SHELL.md, Syntax highlighting |
| semantic tokens, from the parser | over the prompt's colours, in LSP's standard types. type is a struct's or an enum's name, where declared and where used, a parameter's or a field's type, and Type with its members (Type.NUMBER). enumMember is FAST in Mode.FAST. function is a proc's name where declared and where called, clone in git.clone and split in str.split. namespace is str and an import's name, git. parameter is a proc's parameter where declared and as $target inside it, and a named result where declared, host in -> (host: string); a result's type is a type. A constant is a variable with the modifier readonly, where declared, ORG :: ..., and where read, $ORG, in code and in a string. The modifier declaration marks where a name is declared, defaultLibrary a built-in. The statement a mistake is in keeps the prompt's colours alone | ela --check |
The server reads the text as the editor last sent it, saved or not, and finds its imports from
the file's folder. It counts a line's characters in UTF-8 when the editor offers that, in UTF-16
otherwise. It exits with status 0 after the editor's shutdown and exit, and with 1 when its
input ends first.
