Zuri for Visual Studio Code
Language support for Zuri: the Zuri language
server in the editor, with syntax highlighting, snippets, a colour theme
and a Test Explorer for Zuri's own test module.
Everything that understands Zuri code comes from zuri lsp, the language
server that ships with Zuri. The extension starts it for every workspace
holding a .zu file and connects the editor to it.
Features
Writing code
- Completion of the names in scope, the members of what a value holds
(fields, methods, inherited and extension methods, a module's exports,
a built-in type's methods and a dictionary's keys), import paths and
the names a module exports, type names,
@new and the operator
decorators, and doc block tags.
- Completion of names from modules not imported yet, adding the import.
- Signature help while arguments are written, with each parameter's
documentation.
- Hover documentation from doc blocks, with the inferred type of a
variable and the value of a constant.
- Inlay hints naming the parameter each argument goes to, and the
inferred type of a variable.
- Snippets for every statement and declaration, and for tests.
Finding your way
- Go to definition, declaration, type definition and implementation.
- Find references, and highlight every use of a name in the file.
- Call hierarchy and type hierarchy.
- An outline of the file, and a search for declarations across the
workspace.
- Links from each import to the file it loads.
- Reference counts above classes, functions and methods.
Keeping code correct
- Diagnostics as you type: syntax and compile errors, modules and
members that do not exist, names nothing declares, fields set outside
@new that no class declares, and literal arguments of the wrong type
for a typed parameter.
- Unused imports and declarations shown faded, unreachable code too, and
uses of anything marked
@deprecated struck through.
- Quick fixes: add the missing import, correct a misspelt name, remove
an unused import, declare a field.
Changing code
- Rename a declaration across the workspace, refused where the new name
would change what the program does.
- Extract an expression into a variable or statements into a function
or method, and inline a variable or a function, each offered only
where behaviour stays the same.
- Format a file, or a selection, with
zuri fmt.
- Renaming or moving a file updates the relative imports that reach it.
Testing
- Every
describe and it of the workspace in the Test Explorer, run a
file, a suite or one test at a time, with each failure shown on the
line it failed at.
- Run lenses above suites and tests.
Highlighting
- A grammar for the whole language, and semantic highlighting from the
server that colours each name by what it resolves to.
Requirements
Zuri, with its zuri executable on PATH or named by zuri.path. The
language server is part of Zuri itself, so the extension needs nothing
else. Zuri: Check Zuri Installation reports the version found.
Settings
| Setting |
Default |
What it does |
zuri.path |
zuri |
The zuri executable the server runs as |
zuri.trace.server |
off |
Records the messages between the editor and the server |
zuri.root |
empty |
The installation whose standard library is read; empty uses ZURI_ROOT, or the one beside zuri |
zuri.exclude |
[] |
Globs of files never indexed |
zuri.index.workers |
2 |
Isolates that index the workspace in the background |
zuri.diagnostics.enable |
true |
Whether problems are reported |
zuri.diagnostics.scope |
openFiles |
openFiles, or workspace for every file |
zuri.diagnostics.delay |
300 |
Milliseconds after a change before a file is checked |
zuri.diagnostics.unusedHints |
true |
Whether unused declarations are shown faded |
zuri.inlayHints.parameterNames |
literals |
none, literals or all arguments named |
zuri.inlayHints.variableTypes |
false |
Whether inferred variable types are shown |
zuri.codeLens.references |
true |
Whether reference counts are shown |
zuri.completion.autoImport |
true |
Whether names from modules not imported yet are offered |
zuri.completion.callParentheses |
false |
Whether completing a function writes its parentheses |
zuri.testing.codeLens |
true |
Whether suites and tests show lenses that run them |
Commands
- Zuri: Restart Language Server
- Zuri: Show Language Server Output
- Zuri: Check Zuri Installation
When something goes wrong
The Zuri Language Server output shows what the server logs. Set
zuri.trace.server to messages to record every message as well. The
server also writes its log to a file when started with --log <path>.
Other editors use the same server: the Editor Support chapter of the
Zuri book shows how to set up Neovim, Helix, Sublime Text and Emacs.
License
MIT. Copyright, Ore Richard Muyiwa.
| |