ecko lsp

ecko lsp

The language server, speaking LSP over stdin and stdout. You do not normally run it yourself - an editor launches it. See Editor support for setup.

What it provides

  • Diagnostics - the same findings as ecko check, live as you type: undefined names with suggestions, arity, use-before-definition, match exhaustiveness, unwrapped credentials, unused bindings.
  • Completion - names in scope, standard-library modules and their functions, and the global built-ins.
  • Hover - signatures and documentation, including the ## doc comments on your own functions.
  • Go to definition.
  • Document symbols - the outline of a file.
  • Find usages - every reference to the symbol under the cursor, and highlighting of its other occurrences as you move around - both scoped to the open file. Resolution goes through the real scope stack, so a name shadowed in an inner scope resolves to its own declaration, not the outer one. Workspace-wide search is not yet supported, though rename does cross files - see below.
  • Rename - your editor's rename command (F2 in VS Code) renames a symbol and every reference to it, including in other files. A name that only exists inside one file is renamed there. A name the file exports is also rewritten wherever another file reaches it through an import, under whatever alias that file chose - import "./cart.ecko" as c makes it c.total, and that is the spelling updated there. It refuses rather than guesses. Renaming is the one editor action that rewrites files you are not looking at, so anything it cannot resolve exactly comes back as a message instead of a partial edit: a new name that is not a plain identifier or is a keyword, a cursor on a built-in or a standard-library module, or a file that both imports yours and declares its own binding of the same name, where alias.thing cannot be attributed to one of them.
  • Quick fixes - a repair offered alongside the diagnostic: correct a misspelled name to the suggested match, remove an unused import, prefix an unused binding with _, or fill in the missing arms of a non-exhaustive match. An unused function gets no fix - deleting it isn't a safe blind repair.
  • Formatting - the same result as ecko fmt, applied by your editor's format command or on save. It reformats the whole file; formatting just a selection isn't supported yet.
  • Semantic highlighting - colour from the compiler rather than the editor's regex-based grammar: standard-library modules and types are resolved and coloured precisely, and any other capitalised name is coloured as a union variant on the strength of Ecko's naming convention, not because it was checked against a declared variant.

No separate install

The server is the same binary as the compiler. There is no language-server package to install, no version to keep in step with the toolchain, and no possibility of the editor analyzing your code with different rules than the compiler applies - it is literally the same analysis pass.

Debugging it

An editor that shows no diagnostics is usually failing to launch the binary. Check that ecko is on the PATH the editor sees, which is not always the PATH your shell sees, and look at your editor's LSP log.