Editors
Zen C comes with a language server, zc-lsp, which any editor with an LSP client can use. The VS Code extension starts it for you; for other editors, see Other editors.
zc-lsp is installed next to zc (see Install). With the portable executables, it is zc-lsp.com.
VS Code
The Zen C - CE extension is on the VS Code Marketplace and on Open VSX, for VSCodium, Cursor and other editors based on VS Code. Search for "Zen C" in the Extensions view, or run:
The extension looks for zc-lsp in your PATH. If it is somewhere else, set zenc-lang-ce.serverPath to it; if the extension cannot find it, it asks where it is and saves the answer in that setting.
Features
| Feature | What it does |
|---|---|
| Syntax highlighting | Keywords, types, functions, strings and comments, also before the language server starts. |
| Diagnostics | Errors and warnings as you type. |
| Completion | Variables, functions, struct fields, and methods after .. |
| Hover | The type or the signature of the symbol under the cursor, with its documentation. |
| Signature help | The parameters of the function being called, after (. |
| Go to definition and declaration | Jump to where a symbol is defined. |
| Find references | Every use of a symbol in the workspace. |
| Rename | Renames a symbol and its uses. |
| Outline and symbol search | The symbols of the file (Outline view, Ctrl+Shift+O) and of the workspace (Ctrl+T). |
| Semantic highlighting | Colors from the language server: variables, functions, structs, enums, types. |
| Formatting | Format Document, with zc-format's rules. |
| Quick fixes | var → let and const → def, for code from older versions. |
| Breakpoints | Breakpoints in .zc files, for debugging. |
Settings and commands
| Setting | Default | What it does |
|---|---|---|
zenc-lang-ce.serverPath | empty | Path to zc-lsp. Empty: look it up in the PATH. |
zenc-lang-ce.server.enable | true | Start the language server. Off: highlighting and editing support only. |
zenc-lang-ce.server.verbose | false | Start the server with --verbose; its log goes to the "Zen C Language Server" output. |
zenc-lang-ce.trace.server | off | Trace the messages between VS Code and the server: off, messages or verbose. |
The command palette has Zen C: Restart Language Server, for example after installing a new zc-lsp, and Zen C: Show Language Server Output, where its log and traces go.
Debugging
A Zen C program compiled with debug information can be debugged as a C program: the generated C carries #line directives, so the debugger stops at lines of your .zc files and shows their variables.
zc -g turns on the #line directives, but does not pass -g to the C compiler yet (#117). Use -g3, as below.
-
Build with debug information. Give the C compiler
-g3(zcpasses through the options it does not know) and turn optimizations off: -
Install a debugger extension: CodeLLDB on Linux and macOS, or C/C++ with GDB on Windows.
-
Add a task that builds the current file, in
.vscode/tasks.json: -
Add a launch configuration that runs that task first, in
.vscode/launch.json. With CodeLLDB:On Windows, with C/C++ and the GDB of MinGW-w64:
-
Set a breakpoint in a
.zcfile, open it and press F5.
The same works without VS Code: lldb ./app or gdb ./app, then breakpoint set --file app.zc --line 4 (break app.zc:4 in GDB).
Other editors
Any editor with an LSP client can start zc-lsp: it talks LSP over standard input and output, and needs no arguments. Register the .zc extension as a language, then point the client to zc-lsp. zc-lsp explains what it does and how to configure it for a project.
Neovim
In init.lua:
vim..
vim..
Helix
In languages.toml (in the Helix configuration directory, or .helix/languages.toml in a project):
[]
= "zc-lsp"
[[]]
= "zenc"
= "source.zenc"
= ["zc"]
= [".git"]
= "//"
= { = 4, = " " }
= ["zc-lsp"]
hx --health zenc checks that Helix finds zc-lsp. There is no tree-sitter grammar for Zen C yet, so Helix shows the language server's features without syntax highlighting.